mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-14 02:02:19 +00:00
necessary changes to get everyauth working (since can't run
model.fetch() on the server). revisit, this might not be the case
This commit is contained in:
parent
9fd4367a8a
commit
a0611297fa
2 changed files with 20 additions and 2 deletions
|
|
@ -20,11 +20,21 @@ helpers = require('./helpers');
|
|||
helpers.viewHelpers(view);
|
||||
|
||||
get('/:uidParam?', function(page, model, _arg, next) {
|
||||
var uidParam, userId;
|
||||
var q, sess, uidParam, userId;
|
||||
uidParam = _arg.uidParam;
|
||||
if (uidParam === 'privacy' || uidParam === 'terms') {
|
||||
return next();
|
||||
}
|
||||
sess = model.session;
|
||||
if (sess.auth && sess.auth.facebook) {
|
||||
q = model.query('users').withEveryauth('facebook', sess.auth.facebook.id);
|
||||
model.fetch(q, function(err, user) {
|
||||
if (user && user.get('id') !== sess.auth.id) {
|
||||
sess.auth.id = user.get('id');
|
||||
return page.redirect('/');
|
||||
}
|
||||
});
|
||||
}
|
||||
userId = model.get('_userId');
|
||||
return model.subscribe("users." + userId, function(err, user) {
|
||||
var guid, newUser, task, _i, _len, _ref1;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,15 @@ helpers.viewHelpers(view)
|
|||
|
||||
get '/:uidParam?', (page, model, {uidParam}, next) ->
|
||||
#FIXME figure out a better way to do this
|
||||
return next() if (uidParam == 'privacy' or uidParam == 'terms')
|
||||
return next() if (uidParam == 'privacy' or uidParam == 'terms')
|
||||
|
||||
sess = model.session
|
||||
if sess.auth && sess.auth.facebook
|
||||
q = model.query('users').withEveryauth('facebook', sess.auth.facebook.id)
|
||||
model.fetch q, (err, user) ->
|
||||
if (user && user.get('id')!=sess.auth.id)
|
||||
sess.auth.id = user.get('id')
|
||||
return page.redirect('/')
|
||||
|
||||
userId = model.get '_userId'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue