Add Google Signin (#7969)

* Start adding google login

* fix local js issue

* implement syntax suggestions

* fix delete social tests

* Add service for authentication alerts

* fix social login tests

* make suggested google sign in changes

* fix accidentally deleted code

* refactor social network sign in

* fix incorrect find

* implement suggested google sign in changes

* fix(tests): Inject fake Auth module for auth controller

* fix(test): prevent social service from causing page reload

* fix loading user info

* Use lodash's implimentation of find for IE compatibility

* chore: increase test coverage around deletion route

* chore: clean up social auth test

* chore: Fix social login tests

* remove profile from login scope

* fix(api): Allow social accounts to deregister as user has auth backup

* temporarily disable google login button
This commit is contained in:
Phillip Thelen
2016-09-28 12:11:10 +02:00
committed by Matteo Pagliazzi
parent 941000d737
commit e3b484b29a
25 changed files with 465 additions and 150 deletions

View File

@@ -103,14 +103,29 @@ function _setUpNewUser (user) {
return _populateDefaultTasks(user, taskTypes);
}
function _getFacebookName (fb) {
if (!fb) {
return;
}
let possibleName = fb.displayName || fb.name || fb.username;
if (possibleName) {
return possibleName;
}
if (fb.first_name && fb.last_name) {
return `${fb.first_name} ${fb.last_name}`;
}
}
function _setProfileName (user) {
let fb = user.auth.facebook;
let google = user.auth.google;
let localUsername = user.auth.local && user.auth.local.username;
let facebookUsername = fb && (fb.displayName || fb.name || fb.username || `${fb.first_name && fb.first_name} ${fb.last_name}`);
let googleUsername = google && google.displayName;
let anonymous = 'Anonymous';
return localUsername || facebookUsername || anonymous;
return localUsername || _getFacebookName(user.auth.facebook) || googleUsername || anonymous;
}
schema.pre('save', true, function preSaveUser (next, done) {