-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Firebase authentication provider is implemented #3174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,38 +5,37 @@ var admin = require("firebase-admin"); | |
|
||
var firebaseServiceAccount = process.env.FIREBASE_SERVICE_ACCOUNT; | ||
if (firebaseServiceAccount != null) { | ||
admin.initializeApp({ | ||
credential: admin.credential.cert(require(firebaseServiceAccount)) | ||
}); | ||
admin.initializeApp({ | ||
credential: admin.credential.cert(require(firebaseServiceAccount)) | ||
}); | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove empty line |
||
// Returns a promise that fulfills iff this user id is valid. | ||
function validateAuthData(authData) { | ||
if (firebaseServiceAccount == null || firebaseServiceAccount == "") { | ||
throw new Parse.Error(Parse.Error.FILE_READ_ERROR, "Firebase service account file not exists"); | ||
} | ||
|
||
return admin.auth().verifyIdToken(authData.access_token) | ||
.then(function (decodedToken) { | ||
if (decodedToken == null || decodedToken.uid == null || decodedToken.uid == "") { | ||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, "Firebase user not found"); | ||
} | ||
return; | ||
}).catch(function (error) { | ||
console.log(error) | ||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, error.message); | ||
}); | ||
if (firebaseServiceAccount == null || firebaseServiceAccount == "") { | ||
throw new Parse.Error(Parse.Error.FILE_READ_ERROR, "Firebase service account file not exists"); | ||
} | ||
|
||
return admin.auth().verifyIdToken(authData.access_token) | ||
.then(function (decodedToken) { | ||
if (decodedToken == null || decodedToken.uid == null || decodedToken.uid == "") { | ||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, "Firebase user not found"); | ||
} | ||
return; | ||
}).catch(function (error) { | ||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, error.message); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove empty line |
||
} | ||
|
||
// Returns a promise that fulfills if this app id is valid. | ||
function validateAppId() { | ||
return Promise.resolve(); | ||
return Promise.resolve(); | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove empty line |
||
module.exports = { | ||
validateAppId, | ||
validateAuthData | ||
validateAppId, | ||
validateAuthData | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ let wechat = require("./wechat"); | |
let weibo = require("./weibo"); | ||
let firebase = require("./firebase"); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove empty line |
||
|
||
let anonymous = { | ||
validateAuthData: () => { | ||
return Promise.resolve(); | ||
|
@@ -41,7 +42,7 @@ let providers = { | |
qq, | ||
wechat, | ||
weibo, | ||
firebase | ||
firebase | ||
} | ||
|
||
module.exports = function(oauthOptions = {}, enableAnonymousUsers = true) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line