mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 13:47:33 +01:00
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:
committed by
Matteo Pagliazzi
parent
941000d737
commit
e3b484b29a
@@ -2,14 +2,17 @@
|
||||
|
||||
// Make user and settings available for everyone through root scope.
|
||||
habitrpg.controller('SettingsCtrl',
|
||||
['$scope', 'User', '$rootScope', '$http', 'ApiUrl', 'Guide', '$location', '$timeout', 'Content', 'Notification', 'Shared', '$compile',
|
||||
function($scope, User, $rootScope, $http, ApiUrl, Guide, $location, $timeout, Content, Notification, Shared, $compile) {
|
||||
['$scope', 'User', '$rootScope', '$http', 'ApiUrl', 'Guide', '$location', '$timeout', 'Content', 'Notification', 'Shared', 'Social', '$compile',
|
||||
function($scope, User, $rootScope, $http, ApiUrl, Guide, $location, $timeout, Content, Notification, Shared, Social, $compile) {
|
||||
var RELEASE_ANIMAL_TYPES = {
|
||||
pets: 'releasePets',
|
||||
mounts: 'releaseMounts',
|
||||
both: 'releaseBoth',
|
||||
};
|
||||
|
||||
var SOCIAL_AUTH_NETWORKS = Shared.constants.SUPPORTED_SOCIAL_NETWORKS;
|
||||
$scope.SOCIAL_AUTH_NETWORKS = SOCIAL_AUTH_NETWORKS;
|
||||
|
||||
// FIXME we have this re-declared everywhere, figure which is the canonical version and delete the rest
|
||||
// $scope.auth = function (id, token) {
|
||||
// User.authenticate(id, token, function (err) {
|
||||
@@ -287,6 +290,40 @@ habitrpg.controller('SettingsCtrl',
|
||||
return Math.floor(numberOfHourglasses);
|
||||
};
|
||||
|
||||
$scope.hasBackupAuthOption = function(user, checkedNetworkKey) {
|
||||
if (user.auth.local.username) {
|
||||
return true;
|
||||
}
|
||||
return _.find(SOCIAL_AUTH_NETWORKS, function (network) {
|
||||
if (network.key !== checkedNetworkKey) {
|
||||
if (user.auth.hasOwnProperty(network.key)) {
|
||||
return user.auth[network.key].id;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.hasSocialAuth = function (user) {
|
||||
return _.find(SOCIAL_AUTH_NETWORKS, function (network) {
|
||||
if (user.auth.hasOwnProperty(network.key)) {
|
||||
return user.auth[network.key].id;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.deleteSocialAuth = function (networkKey) {
|
||||
var network = _.find(SOCIAL_AUTH_NETWORKS, function (network) {
|
||||
return network.key === networkKey;
|
||||
});
|
||||
|
||||
$http.delete(ApiUrl.get() + "/api/v3/user/auth/social/"+networkKey).success(function(){
|
||||
Notification.text(env.t("detachedSocial", {network: network.name}));
|
||||
User.sync();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.socialLogin = Social.socialLogin;
|
||||
|
||||
function _calculateNextCron() {
|
||||
$scope.dayStart;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user