-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix new registration and changing default authentication method for G…
…oogle using OAuth.
- Loading branch information
1 parent
3af7fad
commit b49b2cb
Showing
2 changed files
with
18 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,15 @@ exports.verify = function (aId, aStrategy, aUsername, aLoggedIn, aDone) { | |
var shasum = crypto.createHash('sha256'); | ||
var digest = null; | ||
var query = {}; | ||
var aIds = []; | ||
var ids = []; | ||
|
||
if (aId instanceof Array) { | ||
aIds = aId.map(function (aId) { | ||
ids = aId.map(function (aId) { | ||
var shasum = crypto.createHash('sha256'); | ||
shasum.update(String(aId)); | ||
return shasum.digest('hex'); | ||
}); | ||
query.auths = { '$in': aIds }; | ||
query.auths = { '$in': ids }; | ||
} else if (aStrategy === 'github') { | ||
// We only keep plaintext ids for GH since that's all we need | ||
digest = aId; | ||
|
@@ -42,9 +42,19 @@ exports.verify = function (aId, aStrategy, aUsername, aLoggedIn, aDone) { | |
|
||
findDeadorAlive(User, query, true, | ||
function (aAlive, aUser, aRemoved) { | ||
var pos = aUser ? aUser.auths.indexOf(digest || aIds[0]) : -1; | ||
var pos = aUser ? aUser.auths.indexOf(digest) : -1; | ||
var opendIdPos = -1; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
sizzlemctwizzle
via email
Author
Member
|
||
if (aRemoved) { aDone(null, false, 'user was removed'); } | ||
|
||
// Set up for OpenId to OAuth Migration | ||
if (!digest && ids.length > 0) { | ||
digest = ids[1]; | ||
if (aUser) { | ||
pos = aUser.auths.indexOf(digest); | ||
opendIdPos = aUser.auths.indexOf(ids[0]); | ||
} | ||
} | ||
|
||
if (!aUser) { | ||
User.findOne({ 'name': aUsername }, function (aErr, aUser) { | ||
if (aUser && aLoggedIn) { | ||
|
@@ -82,9 +92,9 @@ exports.verify = function (aId, aStrategy, aUsername, aLoggedIn, aDone) { | |
aUser.save(function (aErr, aUser) { | ||
return aDone(aErr, aUser); | ||
}); | ||
} else if (aIds.length > 0 && pos > -1) { | ||
} else if (opendIdPos > 0) { | ||
// Migrate from OpenID to OAuth | ||
aUser.auths[pos] = aIds[1]; | ||
aUser.auths[opendIdPos] = digest; | ||
aUser.save(function (aErr, aUser) { | ||
return aDone(aErr, aUser); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This isn't blocking but did you mean to type
openIdIdPos
for the identifier? Took me a bit to figure out what it meant... from a general naming perspective.