Merged release-0.8.0 into develop

master
Keith Irwin 2018-01-22 22:31:32 +00:00
commit fa166d755e
No known key found for this signature in database
GPG Key ID: 378933C743E2BBC0
11 changed files with 51 additions and 70 deletions

View File

@ -1,7 +1,12 @@
# Tracman Server Changelog
###### v 0.7.12
#### develop
###### v0.8.0
* Added check to ensure only the newest location is sent
* Removed buggy login/-out redirects
* [#111](https://github.com/Tracman-org/Server/issues/111) Implemented service worker
* [#116](https://github.com/Tracman-org/Server/issues/116) Switched promises for async/await
* [#64](https://github.com/Tracman-org/Server/issues/64) Started using promises in model methods
* [#63](https://github.com/Tracman-org/Server/issues/63) Disconnect inactive clients
* [#110](https://github.com/Tracman-org/Server/issues/110) Implemented [StandardJS](https://standardjs.com/)
* Removed emojis
* [#113](https://github.com/Tracman-org/Server/issues/113) [#114](https://github.com/Tracman-org/Server/issues/114) Switched to useMongoClient

View File

@ -1,5 +1,5 @@
# <img align="left" src="/static/img/icon/by/48.png" alt="[]" title="The Tracman Logo">Tracman
###### v 0.7.12
# <img align="left" src="/static/img/icon/by/48.png" alt="T" title="The Tracman Logo">Tracman
###### v 0.8.0
node.js application to display a sharable map with user's location.
@ -55,55 +55,35 @@ Tracman will be updated according to [this branching model](http://nvie.com/post
[view full changelog](CHANGELOG.md)
#### develop
#### v0.8.0
* Added check to ensure only the newest location is sent
* Removed buggy login/-out redirects
* [#111](https://github.com/Tracman-org/Server/issues/111) Implemented service worker
* [#116](https://github.com/Tracman-org/Server/issues/116) Switched promises for async/await
* [#64](https://github.com/Tracman-org/Server/issues/64) Started using promises in model methods
* [#63](https://github.com/Tracman-org/Server/issues/63) Disconnect inactive clients
* [#110](https://github.com/Tracman-org/Server/issues/110) Implemented [StandardJS](https://standardjs.com/)
* Removed emojis
* [#113](https://github.com/Tracman-org/Server/issues/113) [#114](https://github.com/Tracman-org/Server/issues/114) Switched to useMongoClient
* [#67](https://github.com/Tracman-org/Server/issues/67) Fixed invisible marker in demo
* Shortened if statements and long lines
#### v0.7.12
#### v0.7.x
* Fixed altitude sign
#### v0.7.10
* Added coinhive
* Updated jQuery
* Added HTML5 shiv
#### v0.7.9
* Updated packages
* Added support for browser geolocation
* Fixed streetview image bugs
* Added sourcemaps for debugging
* Fixed streetview bearing
#### v0.7.8
* [#96](https://github.com/Tracman-org/Server/issues/96) Replaced panorama with static images
#### v0.7.7
* [#96](https://github.com/Tracman-org/Server/issues/96) Continue to update panorama after creating element
#### v0.7.6
* [#100](https://github.com/Tracman-org/Server/issues/100) Moved CSS out of webpack
* Fixed [#108](https://github.com/Tracman-org/Server/issues/108)
#### v0.7.5
* Added pricing to homepage
#### v0.7.4
* Improved debugging
* Fixed bugs [#105](https://github.com/Tracman-org/Server/issues/105) and [#107](https://github.com/Tracman-org/Server/issues/107)
* [#89](https://github.com/Tracman-org/Server/issues/89) Can change marker color
#### v0.7.3
* Fixed [#102](https://github.com/Tracman-org/Server/issues/102) issue creating account
#### v0.7.2
* Added more debugging to fix auth problems
#### v0.7.0
* Bug fixes
## License

View File

@ -38,7 +38,6 @@ module.exports = (passport) => {
// No user with that email
if (!user) {
debug(`No user with that email`)
req.session.next = undefined
return done(null, false, req.flash('warning', 'Incorrect email or password.'))
// User exists
@ -51,11 +50,11 @@ module.exports = (passport) => {
// Password incorrect
if (!res) {
debug(`Incorrect password`)
req.session.next = undefined
return done(null, false, req.flash('warning', 'Incorrect email or password.'))
// Successful login
} else {
if (!user.lastLogin) req.forNewUser = true
user.lastLogin = Date.now()
user.save()
return done(null, user)
@ -87,7 +86,7 @@ module.exports = (passport) => {
if (service === 'google') {
try {
let user = await User.findOne({ 'googleID': parseInt(profileId, 10) })
// User exists with old schema
if (user) {
debug(`User ${user.id} exists with old schema. Lazily updating...`)

View File

@ -17,11 +17,11 @@ module.exports = (app, passport) => {
failureFlash: true
}
const loginCallback = (req, res) => {
debug(`Login callback called... redirecting to ${req.session.next}`)
debug(`Logged in... redirecting to /map`)
req.flash(req.session.flashType, req.session.flashMessage)
req.session.flashType = undefined
req.session.flashMessage = undefined
res.redirect(req.session.next || '/map')
res.redirect('/map'+(req.forNewUser)?'/map?new=1':'')
}
const appLoginCallback = (req, res, next) => {
debug('appLoginCallback called.')
@ -44,8 +44,9 @@ module.exports = (app, passport) => {
.post(passport.authenticate('local', loginOutcome), loginCallback)
app.get('/logout', (req, res) => {
req.logout()
debug(`Logged out, redirecting to /`)
req.flash('success', `You have been logged out.`)
res.redirect(req.session.next || '/')
res.redirect( '/')
})
// Signup
@ -62,7 +63,6 @@ module.exports = (app, passport) => {
// Create a new password token
try {
let [token, expires] = await user.createPassToken()
console.log(token,expires)
debug(`Created password token for user ${user.id} successfully`)
// Figure out expiration time string

View File

@ -65,7 +65,7 @@ module.exports = router
text: req.body.message
})
req.flash('success', `Your message has been sent. `)
res.redirect(req.session.next || '/')
res.redirect('/')
} catch (err) {
mw.throwErr(err, req)
res.redirect('/contact')

View File

@ -174,7 +174,7 @@ router.get('/email/:token', mw.ensureAuth, async (req, res, next) => {
} catch (err) {
mw.throwErr(err, req)
res.redirect(req.session.next || '/settings')
res.redirect('/settings')
}
// Invalid token
@ -296,7 +296,7 @@ router.route('/password/:token')
} else {
debug('New user created password')
req.flash('success', 'Password set. You can use it to log in now. ')
res.redirect('/login?next=/map?new=1')
res.redirect('/login')
}
} catch (err) {

View File

@ -63,7 +63,7 @@ module.exports = {
debug(`Location was set to: ${JSON.stringify(loc)}`)
// Get android timestamp or use server timestamp
if (loc.ts) loc.tim = Date(loc.ts)
if (loc.ts) loc.tim = +loc.ts
else loc.tim = Date.now()
// Check for user and sk32 token
@ -93,19 +93,27 @@ module.exports = {
).message
)
} else {
// Broadcast location
io.to(loc.usr).emit('get', loc)
debug(`Broadcasting ${loc.lat}, ${loc.lon} to ${loc.usr}`)
// Save in db as last seen
user.last = {
lat: parseFloat(loc.lat),
lon: parseFloat(loc.lon),
dir: parseFloat(loc.dir || 0),
spd: parseFloat(loc.spd || 0),
time: loc.tim
// Check that loc is newer than lastLoc
debug(`Checking that loc of ${loc.tim} is newer than last of ${user.last.time.getTime()}...`)
if (!user.last.time || loc.tim > user.last.time.getTime()) {
// Broadcast location
io.to(loc.usr).emit('get', loc)
debug(`Broadcasting ${loc.lat}, ${loc.lon} to ${loc.usr}`)
// Save in db as last seen
user.last = {
lat: parseFloat(loc.lat),
lon: parseFloat(loc.lon),
dir: parseFloat(loc.dir || 0),
spd: parseFloat(loc.spd || 0),
time: loc.tim
}
user.save()
}
user.save()
}
} catch (err) { console.error(err.stack) }
}

View File

@ -1,6 +1,6 @@
{
"name": "tracman",
"version": "0.7.12",
"version": "0.8.0",
"description": "Tracks user's GPS location",
"main": "server.js",
"dependencies": {

View File

@ -82,17 +82,6 @@ let ready_promise_list = []
// Default locals available to all views (keep this after static files)
app.get('*', (req, res, next) => {
// Path for redirects
let nextPath = (
(req.query.next) ? req.query.next
: req.path.substring(0, req.path.indexOf('#')) || req.path)
if (
nextPath.substring(0, 6) !== '/login'||'/admin' &&
nextPath.substring(0, 7) !== 'signup'||'/logout'||'/static'
) {
req.session.next = nextPath + '#'
debug(`Set redirect path to ${nextPath}#`)
}
// User account
res.locals.user = req.user

View File

@ -14,9 +14,9 @@
*/
// Names of the two caches used in this version of the service worker.
// Change to v2, etc. when you update any of the local resources, which will
// Change when you update any of the local resources, which will
// in turn trigger the install event again.
const PRECACHE = 'precache-0.7.12'
const PRECACHE = 'precache-0.8.0'
const RUNTIME = 'runtime'
// A list of local resources we always want to be cached.
@ -46,7 +46,7 @@ self.addEventListener('activate', function(event) {
return Promise.all(cachesToDelete.map( function(cacheToDelete) {
return caches.delete(cacheToDelete)
}))
}).then( function(){ self.clients.claim() })
}).then( function(){ self.clients.claim() )
)
})

View File

@ -109,7 +109,7 @@ describe('Authentication', () => {
.type('form').send({ 'password':TEST_PASSWORD })
// Expect redirect
chai.expect(res).to.redirectTo('/login?next=/map?new=1')
chai.expect(res).to.redirectTo('/login')
// Retrieve user with password saved
let passworded_user = await User.findOne({'email':TEST_EMAIL} )