Merged hotfix-0.6.5 into develop
commit
b8cec7c2da
|
@ -104,6 +104,7 @@ module.exports = (passport)=>{
|
|||
return done(null, user);
|
||||
})
|
||||
.catch( (err)=>{
|
||||
debug(`Failed to save user that exists with old googleId schema!`);
|
||||
mw.throwErr(err,req);
|
||||
return done(err);
|
||||
});
|
||||
|
@ -117,6 +118,7 @@ module.exports = (passport)=>{
|
|||
|
||||
})
|
||||
.catch ( (err)=>{
|
||||
debug(`Failed to search for user with old googleID field. `);
|
||||
mw.throwErr(err,req);
|
||||
return done(err);
|
||||
});
|
||||
|
@ -140,6 +142,7 @@ module.exports = (passport)=>{
|
|||
|
||||
})
|
||||
.catch( (err)=>{
|
||||
debug(`Failed to find user with query: ${query}`);
|
||||
mw.throwErr(err,req);
|
||||
return done(err);
|
||||
});
|
||||
|
@ -150,6 +153,7 @@ module.exports = (passport)=>{
|
|||
debug(`Attempting to connect ${service} account...`);
|
||||
|
||||
// Check for unique profileId
|
||||
debug(`Checking for unique profileId...`);
|
||||
User.findOne(query)
|
||||
.then( (existingUser)=>{
|
||||
|
||||
|
@ -178,6 +182,7 @@ module.exports = (passport)=>{
|
|||
|
||||
})
|
||||
.catch( (err)=>{
|
||||
debug(`Failed to check for unique profileId!`);
|
||||
mw.throwErr(err,req);
|
||||
return done(err);
|
||||
});
|
||||
|
|
|
@ -91,6 +91,7 @@ module.exports = (app, passport) => {
|
|||
res.redirect('/login');
|
||||
})
|
||||
.catch((err)=>{
|
||||
debug(`Failed to email new instructions to continue to ${user.email}!`);
|
||||
mw.throwErr(err,req);
|
||||
res.redirect('/login#signup');
|
||||
});
|
||||
|
@ -140,7 +141,7 @@ module.exports = (app, passport) => {
|
|||
if (existingUser){
|
||||
crypto.randomBytes(6, (err,buf)=>{
|
||||
if (err) {
|
||||
debug('Failed to create random bytest for slug');
|
||||
debug('Failed to create random bytes for slug!');
|
||||
mw.throwErr(err,req);
|
||||
reject();
|
||||
}
|
||||
|
@ -155,7 +156,7 @@ module.exports = (app, passport) => {
|
|||
|
||||
})
|
||||
.catch((err)=>{
|
||||
debug('Failed to create slug');
|
||||
debug('Failed to create slug!');
|
||||
mw.throwErr(err,req);
|
||||
reject();
|
||||
});
|
||||
|
@ -172,7 +173,7 @@ module.exports = (app, passport) => {
|
|||
debug('Creating sk32');
|
||||
crypto.randomBytes(32, (err,buf)=>{
|
||||
if (err) {
|
||||
debug('Failed to create sk32');
|
||||
debug('Failed to create sk32!');
|
||||
mw.throwErr(err,req);
|
||||
reject();
|
||||
}
|
||||
|
@ -189,7 +190,7 @@ module.exports = (app, passport) => {
|
|||
// .then( ()=>{ user.save(); })
|
||||
.then( ()=>{ sendToken(user); })
|
||||
.catch( (err)=>{
|
||||
debug('Failed to save user');
|
||||
debug('Failed to save user after creating slug and sk32!');
|
||||
mw.throwErr(err,req);
|
||||
res.redirect('/login#signup');
|
||||
});
|
||||
|
@ -198,6 +199,7 @@ module.exports = (app, passport) => {
|
|||
|
||||
})
|
||||
.catch( (err)=>{
|
||||
debug(`Failed to check if somebody already has the email ${req.body.email}`);
|
||||
mw.throwErr(err,req);
|
||||
res.redirect('/signup');
|
||||
});
|
||||
|
@ -219,6 +221,7 @@ module.exports = (app, passport) => {
|
|||
req.checkBody('email', 'Please enter a valid email address.').isEmail();
|
||||
req.sanitizeBody('email').normalizeEmail({remove_dots:false});
|
||||
|
||||
// Check if somebody has that email
|
||||
User.findOne({'email':req.body.email})
|
||||
.then( (user)=>{
|
||||
|
||||
|
@ -247,6 +250,7 @@ module.exports = (app, passport) => {
|
|||
req.flash('success', `If an account exists with the email <u>${req.body.email}</u>, an email has been sent there with a password reset link. `);
|
||||
res.redirect('/login');
|
||||
}).catch((err)=>{
|
||||
debug(`Failed to send reset link to ${user.email}`);
|
||||
mw.throwErr(err,req);
|
||||
res.redirect('/login');
|
||||
});
|
||||
|
@ -256,6 +260,7 @@ module.exports = (app, passport) => {
|
|||
}
|
||||
|
||||
}).catch( (err)=>{
|
||||
debug(`Failed to check for if somebody has that email (in reset request)!`);
|
||||
mw.throwErr(err,req);
|
||||
res.redirect('/login/forgot');
|
||||
});
|
||||
|
@ -307,6 +312,7 @@ module.exports = (app, passport) => {
|
|||
res.redirect('/settings');
|
||||
})
|
||||
.catch((err)=>{
|
||||
debug(`Failed to save user after disconnecting ${service} account!`);
|
||||
mw.throwErr(err,req);
|
||||
res.redirect('/settings');
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
|
||||
// Variables
|
||||
var map, pano, marker, elevator;
|
||||
var map, pano, marker, elevator, newLoc;
|
||||
const mapElem = document.getElementById('map'),
|
||||
panoElem = document.getElementById('pano'),
|
||||
socket = io('//'+window.location.hostname);
|
||||
|
@ -186,29 +186,29 @@ socket.on('get', function(loc) {
|
|||
console.log("🌐️ Got location:",loc.lat+", "+loc.lon);
|
||||
|
||||
// Parse location
|
||||
loc = parseLoc(loc);
|
||||
newLoc = parseLoc(loc);
|
||||
|
||||
// Update map
|
||||
if (disp!=='1') {
|
||||
|
||||
// Update time
|
||||
$('#timestamp').text('location updated '+loc.tim);
|
||||
$('#timestamp').text('location updated '+newLoc.tim);
|
||||
|
||||
// Update marker and map center
|
||||
google.maps.event.trigger(map,'resize');
|
||||
map.setCenter({ lat:loc.lat, lng:loc.lon });
|
||||
marker.setPosition({ lat:loc.lat, lng:loc.lon });
|
||||
map.setCenter({ lat:newLoc.lat, lng:newLoc.lon });
|
||||
marker.setPosition({ lat:newLoc.lat, lng:newLoc.lon });
|
||||
|
||||
// Update speed
|
||||
if (mapuser.settings.showSpeed) {
|
||||
$('#spd').text( loc.spd.toFixed() );
|
||||
$('#spd').text( newLoc.spd.toFixed() );
|
||||
}
|
||||
|
||||
// Update altitude
|
||||
if (mapuser.settings.showAlt) {
|
||||
getAltitude({
|
||||
lat:loc.lat,
|
||||
lng:loc.lon
|
||||
lat: newLoc.lat,
|
||||
lng: newLoc.lon
|
||||
}, elevator, function(alt) {
|
||||
if (alt) {
|
||||
$('#alt').text( (mapuser.settings.units=='standard')?(alt*3.28084).toFixed():alt.toFixed() );
|
||||
|
@ -220,7 +220,7 @@ socket.on('get', function(loc) {
|
|||
|
||||
// Update street view
|
||||
if (disp!=='0' && mapuser.settings.showStreetview) {
|
||||
updateStreetView(loc,10);
|
||||
updateStreetView(newLoc,10);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -239,39 +239,41 @@ function getAltitude(loc,elev,cb){
|
|||
}
|
||||
|
||||
// Get street view imagery
|
||||
//TODO: Use global loc object?
|
||||
function getStreetViewData(loc,rad,cb) {
|
||||
if (!sv) { var sv=new google.maps.StreetViewService(); }
|
||||
sv.getPanorama({
|
||||
location: {
|
||||
lat: loc.lat,
|
||||
lng: loc.lon
|
||||
},
|
||||
radius:rad
|
||||
}, function(data,status){ switch (status){
|
||||
// Success
|
||||
case google.maps.StreetViewStatus.OK:
|
||||
cb(data);
|
||||
break;
|
||||
// No results in that radius
|
||||
case google.maps.StreetViewStatus.ZERO_RESULTS:
|
||||
// Square the radius and try again
|
||||
getStreetViewData(loc,rad*rad*.5,cb);
|
||||
break;
|
||||
// Error
|
||||
default:
|
||||
console.error(new Error('❌️ Street view not available: '+status).message);
|
||||
} });
|
||||
// Ensure that the location hasn't changed
|
||||
if (loc===newLoc) {
|
||||
if (!sv) { var sv=new google.maps.StreetViewService(); }
|
||||
sv.getPanorama({
|
||||
location: {
|
||||
lat: loc.lat,
|
||||
lng: loc.lon
|
||||
},
|
||||
radius: rad
|
||||
}, function(data,status){ switch (status){
|
||||
// Success
|
||||
case google.maps.StreetViewStatus.OK:
|
||||
cb(data);
|
||||
break;
|
||||
// No results in that radius
|
||||
case google.maps.StreetViewStatus.ZERO_RESULTS:
|
||||
// Try again with a bigger radius
|
||||
getStreetViewData(loc,rad*2,cb);
|
||||
break;
|
||||
// Error
|
||||
default:
|
||||
console.error(new Error('❌️ Street view not available: '+status).message);
|
||||
} });
|
||||
} else { console.log('loc!==newLoc'); }
|
||||
}
|
||||
|
||||
// Update streetview
|
||||
function updateStreetView(loc) {
|
||||
//console.log("Updating streetview...");
|
||||
|
||||
// Moving
|
||||
// Moving (show stationary image)
|
||||
if (loc.spd>1) {
|
||||
var imgElem = document.getElementById('panoImg');
|
||||
getStreetViewData(loc, 50, function(data){
|
||||
const imgElem = document.getElementById('panoImg');
|
||||
getStreetViewData(loc, 2, function(data){
|
||||
if (!imgElem) {
|
||||
// Create image
|
||||
pano = undefined;
|
||||
|
@ -287,9 +289,9 @@ function updateStreetView(loc) {
|
|||
});
|
||||
}
|
||||
|
||||
// Not moving and pano not set
|
||||
// Not moving and pano not set (create panoramic image)
|
||||
else if (pano==null) {
|
||||
getStreetViewData(loc, 10, function(data){
|
||||
getStreetViewData(loc, 2, function(data){
|
||||
// Create panorama
|
||||
$('#pano').empty();
|
||||
const panoOptions = {
|
||||
|
@ -305,6 +307,7 @@ function updateStreetView(loc) {
|
|||
pano.setPano(data.location.pano);
|
||||
pano.setPov({
|
||||
pitch: 0,
|
||||
// Point towards users's location from street
|
||||
heading: Math.atan((loc.lon-data.location.latLng.lng())/(loc.lat-data.location.latLng.lat()))*(180/Math.PI)
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue