From 503fd9ff51649bbf26a77c7593505e81291adb2b Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 17 Jan 2015 18:54:03 -0700 Subject: [PATCH] refactor(services): remove un-used authService, cleanup authCtrl --- public/js/app.js | 2 +- public/js/controllers/authCtrl.js | 2 +- public/js/services/authServices.js | 100 ----------------------------- public/js/static.js | 2 +- public/manifest.json | 1 - 5 files changed, 3 insertions(+), 104 deletions(-) delete mode 100644 public/js/services/authServices.js diff --git a/public/js/app.js b/public/js/app.js index a5bcb6c66a..4b5a38b9fe 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -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 diff --git a/public/js/controllers/authCtrl.js b/public/js/controllers/authCtrl.js index 321058ae6f..a167ecb309 100644 --- a/public/js/controllers/authCtrl.js +++ b/public/js/controllers/authCtrl.js @@ -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) { diff --git a/public/js/services/authServices.js b/public/js/services/authServices.js deleted file mode 100644 index 5c7dc90be9..0000000000 --- a/public/js/services/authServices.js +++ /dev/null @@ -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() {} - } -}]); diff --git a/public/js/static.js b/public/js/static.js index a192a301db..8f88fb3551 100644 --- a/public/js/static.js +++ b/public/js/static.js @@ -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') diff --git a/public/manifest.json b/public/manifest.json index 03df4c4535..15deca809c 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -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",