duncangrant commented on a change in pull request #211:
URL: https://github.com/apache/brooklyn-ui/pull/211#discussion_r644865960



##########
File path: ui-modules/login/app/views/main/main.controller.js
##########
@@ -47,18 +47,28 @@ export function loginStateController($scope, $http, 
$window, brBrandInfo) {
     $scope.$emit(HIDE_INTERSTITIAL_SPINNER_EVENT);
     $scope.getBrandedText = brBrandInfo.getBrandedText;
 
+    let loginController = this;
+    loginController.error = {};
+
+    var testAuthReq = {
+        method: 'HEAD',
+        url: '/v1/server/up/extended'
+    }
+
+    // If the user is already logged in then redirect to home
+    $http(testAuthReq).then( () => {$window.location.href = '/';} );

Review comment:
       I think that there is a more angularjs way to redirect but I'm not sure 
I understand what it is.

##########
File path: ui-modules/login/app/views/main/main.controller.js
##########
@@ -47,18 +47,28 @@ export function loginStateController($scope, $http, 
$window, brBrandInfo) {
     $scope.$emit(HIDE_INTERSTITIAL_SPINNER_EVENT);
     $scope.getBrandedText = brBrandInfo.getBrandedText;
 
+    let loginController = this;
+    loginController.error = {};
+
+    var testAuthReq = {
+        method: 'HEAD',
+        url: '/v1/server/up/extended'
+    }
+
+    // If the user is already logged in then redirect to home
+    $http(testAuthReq).then( () => {$window.location.href = '/';} );
+
     $scope.login = (user)=> {
         var req = {
-            method: 'GET',
-            url: '/',
+            method: 'HEAD',
+            url: '/v1/server/up/extended',
             headers: {
                 'Authorization': 'Basic ' + btoa(user.name +":" + 
user.password)
             }
         }
 // ui registry metadata
         $http(req)
-            .then(function () {
-                $window.location.href = '/';
-            });
+            .then(() => { $window.location.href = '/'; },
+                () => { $window.alert("Login Failed") ; 
loginController.error.loginFailed = "Login Failed" });

Review comment:
       Alerting works here but feels old / odd and would be better inline but I 
can't see how to get the loginFailed error to appear on. the form,

##########
File path: ui-modules/login/app/views/main/main.template.html
##########
@@ -20,6 +20,9 @@
     <div class="row">
         <div class="col-md-4 col-md-offset-4 col-sm-12">
             <form>
+                <p ng-if="error['loginFailed']">

Review comment:
       This is a test

##########
File path: ui-modules/utils/server-status/server-status.js
##########
@@ -65,6 +65,9 @@ export function BrServerStatusDirective() {
                 }else if(response.status === 404) {
                     state = BrServerStatusModalController.STATES.NO_CONNECTION;
                 }else if(response.status === 401 || response.status === 403 ) {
+                    if( response.headers("LOGIN_PAGE")) {
+                        $window.location.href = '/' + 
response.headers("LOGIN_PAGE");

Review comment:
       As before I'm not sure this is the angularjs way

##########
File path: ui-modules/utils/server-status/server-status.js
##########
@@ -65,6 +65,9 @@ export function BrServerStatusDirective() {
                 }else if(response.status === 404) {
                     state = BrServerStatusModalController.STATES.NO_CONNECTION;
                 }else if(response.status === 401 || response.status === 403 ) {
+                    if( response.headers("LOGIN_PAGE")) {

Review comment:
       Is it really bad practice to invent response headers?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to