diff --git a/client/app/app.js b/client/app/app.js
index eaeae5e..b436a1d 100755
--- a/client/app/app.js
+++ b/client/app/app.js
@@ -17,20 +17,19 @@ angular.module('dssWebApp', [
'angulartics',
'ngClipboard',
'angular-jwt',
- 'http-auth-interceptor',
'angular-smilies',
'satellizer',
'angulartics.google.analytics'
])
.config(function ($stateProvider, $sceDelegateProvider, $httpProvider, $urlRouterProvider, $locationProvider, $provide, $authProvider,
- ngClipProvider, jwtInterceptorProvider, $analyticsProvider, dialogsProvider, DSProvider, DSHttpAdapterProvider,
+ ngClipProvider, $analyticsProvider, dialogsProvider, DSProvider, DSHttpAdapterProvider,
SERVER_CONFIG, STORAGE) {
$urlRouterProvider
.otherwise('/');
//$httpProvider.defaults.headers.common.Accept = 'application/json';
$httpProvider.defaults.useXDomain = true;
- $httpProvider.interceptors.push('AuthInterceptor');
+ //$httpProvider.interceptors.push('AuthInterceptor');
$authProvider.baseUrl = SERVER_CONFIG.apiUrl + '/';
$authProvider.loginUrl = '_a/';
@@ -54,7 +53,9 @@ angular.module('dssWebApp', [
url: '_a/?backend=twitter'
});
$authProvider.google({
- clientId: '248170132962-5km115budk9h84raa26hdmnnqdj8ivkl.apps.googleusercontent.com'
+ clientId: '248170132962-5km115budk9h84raa26hdmnnqdj8ivkl.apps.googleusercontent.com',
+ redirectUri: 'http://ext-test.deepsouthsounds.com:9000/',
+ url: '/_a/?backend=google',
});
ngClipProvider.setPath("bower_components/zeroclipboard/dist/ZeroClipboard.swf");
@@ -105,6 +106,8 @@ angular.module('dssWebApp', [
//ensure login before state change
$rootScope.$on('$stateChangeStart', function (event, toState, toParams) {
+
+ /*
if (!$rootScope.currentUser && Session.getLocalToken() != null && Session.getBackend()) {
LoginService.loginUser().then(function (user) {
LoginService.getUserProfile()
@@ -130,6 +133,6 @@ angular.module('dssWebApp', [
}
});
event.preventDefault();
- }
+ }*/
});
});
diff --git a/client/app/main.controller.js b/client/app/main.controller.js
index 9770ac8..77ccb25 100755
--- a/client/app/main.controller.js
+++ b/client/app/main.controller.js
@@ -1,14 +1,24 @@
'use strict';
angular.module('dssWebApp')
- .controller('MainCtrl', function ($scope, $rootScope, $http, $state, dialogs, logger, authService, SocketService, AudioService,
+ .controller('MainCtrl', function ($scope, $rootScope, $http, $state, $auth,
+ dialogs, logger, SocketService, AudioService,
MixModel, UserModel, LoginService, Session, SERVER_CONFIG, CHAT_EVENTS, AUTH_EVENTS) {
$scope.isAuthorized = LoginService.isAuthorized;
$scope.isAuthenticated = LoginService.isAuthenticated;
$scope.currentPath = '';
$scope.chatVisible = false;
$rootScope.isMessaging = false;
-
+ $rootScope.$on('$stateChangeStart', function (event, toState, toParams) {
+ if ($auth.isAuthenticated()) {
+ LoginService.getUserProfile()
+ .then(function (user) {
+ $rootScope.setCurrentUser(user);
+ $rootScope.connectSockets();
+ return $state.go(toState.name, toParams);
+ });
+ }
+ });
$rootScope.safeApply = function (fn) {
var phase = this.$root.$$phase;
if (phase == '$apply' || phase == '$digest') {
@@ -59,20 +69,6 @@ angular.module('dssWebApp')
$rootScope.connectSockets();
});
- $scope.$on('event:auth-loginRequired', function (rejection) {
- console.log("Refreshing token");
- LoginService.getJwtToken(Session.getLocalToken(), Session.getBackend())
- .then(function (result) {
- authService.loginConfirmed(result, function (config) {
- config.headers = config.headers || {};
- config.headers.Authorization = 'JWT ' + Session.getToken();
- return config;
- });
- }, function (reason, code) {
- console.error(reason, code);
- });
- });
-
$scope.setCurrentPath = function (path) {
$scope.currentPath = path;
};
diff --git a/client/app/services/auth/auth.interceptor.js b/client/app/services/auth/auth.interceptor.js
deleted file mode 100644
index a34d0b0..0000000
--- a/client/app/services/auth/auth.interceptor.js
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict';
-angular.module('dssWebApp')
- .factory('AuthInterceptor', function ($q, jwtHelper, Session) {
- return {
- request: addToken
- };
- function addToken(config) {
- var token = Session.getToken();
- if (token) {
- config.headers = config.headers || {};
- config.headers.Authorization = 'JWT ' + token;
- }
- return config;
- }
- });
diff --git a/client/app/services/auth/httpInterceptor.js b/client/app/services/auth/httpInterceptor.js
deleted file mode 100644
index fb59a56..0000000
--- a/client/app/services/auth/httpInterceptor.js
+++ /dev/null
@@ -1,138 +0,0 @@
-/*global angular:true, browser:true */
-
-/**
- * @license HTTP Auth Interceptor Module for AngularJS
- * (c) 2012 Witold Szczerba
- * License: MIT
- */
-(function () {
- 'use strict';
-
- angular.module('http-auth-interceptor', ['http-auth-interceptor-buffer'])
-
- .factory('authService', ['$rootScope', 'httpBuffer', function ($rootScope, httpBuffer) {
- return {
- /**
- * Call this function to indicate that authentication was successfull and trigger a
- * retry of all deferred requests.
- * @param data an optional argument to pass on to $broadcast which may be useful for
- * example if you need to pass through details of the user that was logged in
- */
- loginConfirmed: function (data, configUpdater) {
- var updater = configUpdater || function (config) {
- return config;
- };
- $rootScope.$broadcast('event:auth-loginConfirmed', data);
- httpBuffer.retryAll(updater);
- },
-
- /**
- * Call this function to indicate that authentication should not proceed.
- * All deferred requests will be abandoned or rejected (if reason is provided).
- * @param data an optional argument to pass on to $broadcast.
- * @param reason if provided, the requests are rejected; abandoned otherwise.
- */
- loginCancelled: function (data, reason) {
- httpBuffer.rejectAll(reason);
- $rootScope.$broadcast('event:auth-loginCancelled', data);
- },
-
- /**
- * Call this function to make a function onto every object in the httpBuffer
- * This allows us to modify the requests
- */
- transformRequests: function (func) {
- httpBuffer.transform(func);
- }
- };
- }])
-
- /**
- * $http interceptor.
- * On 401 response (without 'ignoreAuthModule' option) stores the request
- * and broadcasts 'event:angular-auth-loginRequired'.
- */
- .config(['$httpProvider', function ($httpProvider) {
- $httpProvider.interceptors.push(['$rootScope', '$q', 'httpBuffer', function ($rootScope, $q, httpBuffer) {
- return {
- responseError: function (rejection) {
- if ((rejection.status === 401 || rejection.status === 403) && !rejection.config.ignoreAuthModule) {
- var deferred = $q.defer();
- httpBuffer.append(rejection.config, deferred);
- $rootScope.$broadcast('event:auth-loginRequired', rejection);
- return deferred.promise;
- }
- // otherwise, default behaviour
- return $q.reject(rejection);
- }
- };
- }]);
- }]);
-
- /**
- * Private module, a utility, required internally by 'http-auth-interceptor'.
- */
- angular.module('http-auth-interceptor-buffer', [])
-
- .factory('httpBuffer', ['$injector', function ($injector) {
- /** Holds all the requests, so they can be re-requested in future. */
- var buffer = [];
-
- /** Service initialized later because of circular dependency problem. */
- var $http;
-
- function retryHttpRequest(config, deferred) {
- function successCallback(response) {
- deferred.resolve(response);
- }
-
- function errorCallback(response) {
- deferred.reject(response);
- }
-
- $http = $http || $injector.get('$http');
- $http(config).then(successCallback, errorCallback);
- }
-
- return {
- /**
- * Appends HTTP request configuration object with deferred response attached to buffer.
- */
- append: function (config, deferred) {
- buffer.push({
- config: config,
- deferred: deferred
- });
- },
-
- /**
- * Apply a function to every call in the buffer array
- */
- transform: function (func) {
- buffer = buffer.map(func);
- },
-
- /**
- * Abandon or reject (if reason provided) all the buffered requests.
- */
- rejectAll: function (reason) {
- if (reason) {
- for (var i = 0; i < buffer.length; ++i) {
- buffer[i].deferred.reject(reason);
- }
- }
- buffer = [];
- },
-
- /**
- * Retries all the buffered requests clears the buffer.
- */
- retryAll: function (updater) {
- for (var i = 0; i < buffer.length; ++i) {
- retryHttpRequest(updater(buffer[i].config), buffer[i].deferred);
- }
- buffer = [];
- }
- };
- }]);
-})();
diff --git a/client/app/services/auth/login.service.js b/client/app/services/auth/login.service.js
index 5a21f1c..3c8ecdb 100644
--- a/client/app/services/auth/login.service.js
+++ b/client/app/services/auth/login.service.js
@@ -77,14 +77,11 @@ angular.module('dssWebApp')
function logoutUser() {
var defer = $q.defer();
- hello.logout(Session.getBackend())
- .then(function () {
- Session.destroy();
- defer.resolve();
- }, function () {
- Session.destroy();
+ $auth.logout()
+ .then(function(){
defer.resolve();
});
+
return defer.promise;
}
});
diff --git a/client/index.html b/client/index.html
index d822013..29c39d7 100644
--- a/client/index.html
+++ b/client/index.html
@@ -193,8 +193,6 @@
-
-