You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/08/23 16:45:06 UTC

[1/2] incubator-trafficcontrol git commit: refactored how tokin login works to ensure tokin login is complete before attempting to resolve other dependencies that need the authentication cookie

Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master 71978394f -> 86d098d72


refactored how tokin login works to ensure tokin login is complete before attempting to resolve other dependencies that need the authentication cookie


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/98092836
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/98092836
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/98092836

Branch: refs/heads/master
Commit: 98092836c2ae5ac3382245e1b3645eefbda1c7b6
Parents: 7197839
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Wed Aug 23 10:33:36 2017 -0600
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Wed Aug 23 10:43:40 2017 -0600

----------------------------------------------------------------------
 .../app/src/common/api/AuthService.js           | 15 +++++++-
 .../app/src/common/api/UserService.js           | 37 +++++++-------------
 .../src/modules/private/PrivateController.js    | 27 ++++++++++++++
 traffic_portal/app/src/modules/private/index.js | 12 +++++--
 4 files changed, 64 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/98092836/traffic_portal/app/src/common/api/AuthService.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/common/api/AuthService.js b/traffic_portal/app/src/common/api/AuthService.js
index 4fff7e4..463a99b 100644
--- a/traffic_portal/app/src/common/api/AuthService.js
+++ b/traffic_portal/app/src/common/api/AuthService.js
@@ -40,8 +40,21 @@ var AuthService = function($rootScope, $http, $state, $location, $q, $state, htt
     };
 
     this.tokenLogin = function(token) {
+        var deferred = $q.defer();
+
         userModel.resetUser();
-        return httpService.post(ENV.api['root'] + 'user/login/token', { t: token });
+
+        $http.post(ENV.api['root'] + "user/login/token", { t: token })
+            .then(
+                function() {
+                    deferred.resolve();
+                },
+                function() {
+                    deferred.reject();
+                }
+            );
+
+        return deferred.promise;
     };
 
     this.logout = function() {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/98092836/traffic_portal/app/src/common/api/UserService.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/common/api/UserService.js b/traffic_portal/app/src/common/api/UserService.js
index 1a51934..6d45f96 100644
--- a/traffic_portal/app/src/common/api/UserService.js
+++ b/traffic_portal/app/src/common/api/UserService.js
@@ -22,31 +22,20 @@ var UserService = function(Restangular, $http, $location, $q, authService, httpS
     var service = this;
 
     this.getCurrentUser = function() {
-        var token = $location.search().token,
-            deferred = $q.defer();
-
-        if (angular.isDefined(token)) {
-            $location.search('token', null); // remove the token query param
-            authService.tokenLogin(token)
-                .then(
-                    function(response) {
-                        service.getCurrentUser();
-                    }
-                );
-        } else {
-            $http.get(ENV.api['root'] + "user/current")
-                .then(
-                    function(result) {
-                        userModel.setUser(result.data.response);
-                        deferred.resolve(result.data.response);
-                    },
-                    function(fault) {
-                        deferred.reject(fault);
-                    }
-                );
+        var deferred = $q.defer();
 
-            return deferred.promise;
-        }
+        $http.get(ENV.api['root'] + "user/current")
+            .then(
+                function(result) {
+                    userModel.setUser(result.data.response);
+                    deferred.resolve(result.data.response);
+                },
+                function(fault) {
+                    deferred.reject(fault);
+                }
+            );
+
+        return deferred.promise;
     };
 
     this.resetPassword = function(email) {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/98092836/traffic_portal/app/src/modules/private/PrivateController.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/modules/private/PrivateController.js b/traffic_portal/app/src/modules/private/PrivateController.js
new file mode 100644
index 0000000..9b815dc
--- /dev/null
+++ b/traffic_portal/app/src/modules/private/PrivateController.js
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+var PrivateController = function($location) {
+
+	$location.search('token', null); // remove the token query param if it exists
+
+};
+
+PrivateController.$inject = ['$location'];
+module.exports = PrivateController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/98092836/traffic_portal/app/src/modules/private/index.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/modules/private/index.js b/traffic_portal/app/src/modules/private/index.js
index 7ba33c3..27cfecf 100644
--- a/traffic_portal/app/src/modules/private/index.js
+++ b/traffic_portal/app/src/modules/private/index.js
@@ -18,6 +18,7 @@
  */
 
 module.exports = angular.module('trafficPortal.private', [])
+    .controller('PrivateController', require('./PrivateController'))
     .config(function($stateProvider, $urlRouterProvider) {
         $stateProvider
             .state('trafficPortal.private', {
@@ -37,11 +38,18 @@ module.exports = angular.module('trafficPortal.private', [])
                         controller: 'MessageController'
                     },
                     content: {
-                        templateUrl: 'modules/private/private.tpl.html'
+                        templateUrl: 'modules/private/private.tpl.html',
+                        controller: 'PrivateController'
                     }
                 },
                 resolve: {
-                    currentUser: function($state, userService, userModel) {
+                    tokenLogin: function($location, authService) {
+                        var token = $location.search().token; // if there is a token query param, attempt to login with it
+                        if (angular.isDefined(token)) {
+                            return authService.tokenLogin(token);
+                        }
+                    },
+                    currentUser: function(tokenLogin, $state, userService, userModel) {
                         if (userModel.loaded) {
                             return userModel.user;
                         } else {


[2/2] incubator-trafficcontrol git commit: This closes #857.

Posted by da...@apache.org.
This closes #857.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/86d098d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/86d098d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/86d098d7

Branch: refs/heads/master
Commit: 86d098d72e6db727d5fadc4ef2c6f8eebd051fbd
Parents: 9809283
Author: Dan Kirkwood <da...@gmail.com>
Authored: Wed Aug 23 10:44:55 2017 -0600
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Wed Aug 23 10:44:55 2017 -0600

----------------------------------------------------------------------

----------------------------------------------------------------------