GUACAMOLE-1756: Display login failures regardless of whether the interactive login form was used.

This commit is contained in:
Michael Jumper
2023-03-22 14:08:22 -07:00
parent 8dc5bebd29
commit c21ee0f830
3 changed files with 69 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
const SESSION_VALIDITY_RECHECK_INTERVAL = 15000; const SESSION_VALIDITY_RECHECK_INTERVAL = 15000;
// Required types // Required types
const Error = $injector.get('Error');
const ManagedClientState = $injector.get('ManagedClientState'); const ManagedClientState = $injector.get('ManagedClientState');
// Required services // Required services
@@ -110,6 +111,11 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
*/ */
var ApplicationState = { var ApplicationState = {
/**
* A non-interactive authentication attempt failed.
*/
AUTOMATIC_LOGIN_REJECTED : 'automaticLoginRejected',
/** /**
* The application has fully loaded but is awaiting credentials from * The application has fully loaded but is awaiting credentials from
* the user before proceeding. * the user before proceeding.
@@ -323,6 +329,25 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
}); });
// Alert user to authentication errors that occur in the absence of an
// interactive login form
$scope.$on('guacLoginFailed', function loginFailed(event, parameters, error) {
// All errors related to an interactive login form are handled elsewhere
if ($scope.applicationState === ApplicationState.AWAITING_CREDENTIALS
|| error.type === Error.Type.INSUFFICIENT_CREDENTIALS
|| error.type === Error.Type.INVALID_CREDENTIALS)
return;
$scope.applicationState = ApplicationState.AUTOMATIC_LOGIN_REJECTED;
$scope.page.title = 'APP.NAME';
$scope.page.bodyClassName = '';
$scope.reAuthenticating = false;
$scope.fatalError = error;
});
// Replace absolutely all content with an error message if the page itself // Replace absolutely all content with an error message if the page itself
// cannot be displayed due to an error // cannot be displayed due to an error
$scope.$on('guacFatalPageError', function fatalPageError(error) { $scope.$on('guacFatalPageError', function fatalPageError(error) {

View File

@@ -0,0 +1,30 @@
/*
* 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.
*/
.automatic-login-rejected-modal guac-modal {
background: white;
z-index: 20;
}
.automatic-login-rejected-modal .notification {
display: inline-block;
max-width: 5in;
padding: 1em;
width: 100%;
}

View File

@@ -64,6 +64,20 @@
</guac-modal> </guac-modal>
</div> </div>
<!-- Authentication error without a corresponding login form -->
<div class="automatic-login-rejected-modal" ng-switch-when="automaticLoginRejected">
<guac-modal>
<div class="notification">
<p translate="{{ fatalError.translatableMessage.key }}"
translate-values="{{ fatalError.translatableMessage.variables }}"></p>
<p>
<button translate="APP.ACTION_LOGIN_AGAIN" ng-disabled="reAuthenticating"
ng-click="reAuthenticate()"></button>
</p>
</div>
</guac-modal>
</div>
<!-- Login screen for logged-out users --> <!-- Login screen for logged-out users -->
<guac-login ng-switch-when="awaitingCredentials" <guac-login ng-switch-when="awaitingCredentials"
help-text="loginHelpText" help-text="loginHelpText"