refactor(services): remove un-used authService, cleanup authCtrl

This commit is contained in:
Tyler Renelle 2015-01-17 18:54:03 -07:00
parent 2306b7c572
commit 503fd9ff51
5 changed files with 3 additions and 104 deletions

View file

@ -1,7 +1,7 @@
"use strict";
window.habitrpg = angular.module('habitrpg',
['authCtrl', 'ui.bootstrap', 'ui.keypress', 'ui.router', 'chieffancypants.loadingBar', 'At', 'infinite-scroll', 'ui.select2', 'angular.filter', 'ngResource'])
['ui.bootstrap', 'ui.keypress', 'ui.router', 'chieffancypants.loadingBar', 'At', 'infinite-scroll', 'ui.select2', 'angular.filter', 'ngResource'])
// @see https://github.com/angular-ui/ui-router/issues/110 and https://github.com/HabitRPG/habitrpg/issues/1705
// temporary hack until they have a better solution

View file

@ -4,7 +4,7 @@
The authentication controller (login & facebook)
*/
angular.module('authCtrl', [])
angular.module('habitrpg')
.controller("AuthCtrl", ['$scope', '$rootScope', 'User', '$http', '$location', '$window','ApiUrl', '$modal',
function($scope, $rootScope, User, $http, $location, $window, ApiUrl, $modal) {

View file

@ -1,100 +0,0 @@
'use strict';
/**
* Services that persists and retrieves user from localStorage.
* FIXME is this file ever used?
*/
var facebook = {}
angular.module('habitrpg').factory('Facebook',
['$http', '$location', 'User', 'ApiUrl',
function($http, $location, User, ApiUrl) {
//TODO FB.init({appId: '${section.parameters['facebook.app.id']}', status: true, cookie: true, xfbml: true});
var auth, user = User.user;
facebook.handleStatusChange = function(session) {
if (session.authResponse) {
FB.api('/me', {
fields: 'name, picture, email'
}, function(response) {
console.log(response.error)
if (!response.error) {
var data = {
name: response.name,
facebook_id: response.id,
email: response.email
}
$http.post(ApiUrl.get() + '/api/v2/user/auth/facebook', data).success(function(data, status, headers, config) {
User.authenticate(data.id, data.token, function(err) {
if (!err) {
alert(window.env.t('loginSuccess'));
$location.path("/habit");
}
});
}).error(function(response) {
console.log('error')
})
} else {
alert('napaka')
}
//clearAction();
});
} else {
document.body.className = 'not_connected';
//clearAction();
}
}
return {
authUser: function() {
FB.Event.subscribe('auth.statusChange', facebook.handleStatusChange);
},
getAuth: function() {
return auth;
},
login: function() {
FB.login(null, {
scope: 'email'
});
},
logout: function() {
FB.logout(function(response) {
window.location.reload();
});
}
}
}])
.factory('LocalAuth',
['$http', 'User',
function($http, User) {
var auth,
user = User.user;
return {
getAuth: function() {
return auth;
},
login: function() {
user.id = '';
user.apiToken = '';
User.authenticate();
return;
},
logout: function() {}
}
}]);

View file

@ -1,6 +1,6 @@
"use strict";
window.habitrpg = angular.module('habitrpg', ['chieffancypants.loadingBar', 'authCtrl', 'ui.bootstrap'])
window.habitrpg = angular.module('habitrpg', ['chieffancypants.loadingBar', 'ui.bootstrap'])
.constant("API_URL", "")
.constant("STORAGE_USER_ID", 'habitrpg-user')
.constant("STORAGE_SETTINGS_ID", 'habit-mobile-settings')

View file

@ -39,7 +39,6 @@
"js/app.js",
"bower_components/habitrpg-shared/script/config.js",
"js/services/sharedServices.js",
"js/services/authServices.js",
"js/services/notificationServices.js",
"bower_components/habitrpg-shared/script/userServices.js",
"bower_components/habitrpg-shared/script/directives.js",