mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-1756: Merge login failure UI for when no interactive login form was used.
This commit is contained in:
@@ -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.
|
||||||
@@ -278,6 +284,22 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
|
|||||||
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current overall state of the client side of the
|
||||||
|
* application to the given value. Possible values are defined by
|
||||||
|
* {@link ApplicationState}. The title and class associated with the
|
||||||
|
* current page are automatically reset to the standard values applicable
|
||||||
|
* to the application as a whole (rather than any specific page).
|
||||||
|
*
|
||||||
|
* @param {!string} state
|
||||||
|
* The state to assign, as defined by {@link ApplicationState}.
|
||||||
|
*/
|
||||||
|
const setApplicationState = function setApplicationState(state) {
|
||||||
|
$scope.applicationState = state;
|
||||||
|
$scope.page.title = 'APP.NAME';
|
||||||
|
$scope.page.bodyClassName = '';
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigates the user back to the root of the application (or reloads the
|
* Navigates the user back to the root of the application (or reloads the
|
||||||
* current route and controller if the user is already there), effectively
|
* current route and controller if the user is already there), effectively
|
||||||
@@ -300,9 +322,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
|
|||||||
// Display login screen if a whole new set of credentials is needed
|
// Display login screen if a whole new set of credentials is needed
|
||||||
$scope.$on('guacInvalidCredentials', function loginInvalid(event, parameters, error) {
|
$scope.$on('guacInvalidCredentials', function loginInvalid(event, parameters, error) {
|
||||||
|
|
||||||
$scope.applicationState = ApplicationState.AWAITING_CREDENTIALS;
|
setApplicationState(ApplicationState.AWAITING_CREDENTIALS);
|
||||||
$scope.page.title = 'APP.NAME';
|
|
||||||
$scope.page.bodyClassName = '';
|
|
||||||
|
|
||||||
$scope.loginHelpText = null;
|
$scope.loginHelpText = null;
|
||||||
$scope.acceptedCredentials = {};
|
$scope.acceptedCredentials = {};
|
||||||
@@ -313,9 +333,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
|
|||||||
// Prompt for remaining credentials if provided credentials were not enough
|
// Prompt for remaining credentials if provided credentials were not enough
|
||||||
$scope.$on('guacInsufficientCredentials', function loginInsufficient(event, parameters, error) {
|
$scope.$on('guacInsufficientCredentials', function loginInsufficient(event, parameters, error) {
|
||||||
|
|
||||||
$scope.applicationState = ApplicationState.AWAITING_CREDENTIALS;
|
setApplicationState(ApplicationState.AWAITING_CREDENTIALS);
|
||||||
$scope.page.title = 'APP.NAME';
|
|
||||||
$scope.page.bodyClassName = '';
|
|
||||||
|
|
||||||
$scope.loginHelpText = error.translatableMessage;
|
$scope.loginHelpText = error.translatableMessage;
|
||||||
$scope.acceptedCredentials = parameters;
|
$scope.acceptedCredentials = parameters;
|
||||||
@@ -323,16 +341,27 @@ 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;
|
||||||
|
|
||||||
|
setApplicationState(ApplicationState.AUTOMATIC_LOGIN_REJECTED);
|
||||||
|
$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) {
|
||||||
|
setApplicationState(ApplicationState.FATAL_ERROR);
|
||||||
$scope.applicationState = ApplicationState.FATAL_ERROR;
|
|
||||||
$scope.page.title = 'APP.NAME';
|
|
||||||
$scope.page.bodyClassName = '';
|
|
||||||
|
|
||||||
$scope.fatalError = error;
|
$scope.fatalError = error;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Replace the overall user interface with an informational message if the
|
// Replace the overall user interface with an informational message if the
|
||||||
|
@@ -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%;
|
||||||
|
}
|
@@ -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"
|
||||||
|
Reference in New Issue
Block a user