mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-08 22:21:22 +00:00
GUAC-1176: Validate new password set due to expiration. Allow errors dialogs during login process.
This commit is contained in:
@@ -64,6 +64,26 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
||||
var $route = $injector.get('$route');
|
||||
var authenticationService = $injector.get('authenticationService');
|
||||
|
||||
/**
|
||||
* An action to be provided along with the object assigned to
|
||||
* $scope.loginStatus which closes the currently-shown status dialog.
|
||||
*/
|
||||
var ACKNOWLEDGE_ACTION = {
|
||||
name : "LOGIN.ACTION_ACKNOWLEDGE",
|
||||
// Handle action
|
||||
callback : function acknowledgeCallback() {
|
||||
$scope.loginStatus = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The currently-visible notification describing login status, or false
|
||||
* if no notification should be shown.
|
||||
*
|
||||
* @type Notification|Boolean|Object
|
||||
*/
|
||||
$scope.loginStatus = false;
|
||||
|
||||
/**
|
||||
* Whether an error occurred during login.
|
||||
*
|
||||
@@ -110,12 +130,15 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
||||
*/
|
||||
$scope.login = function login() {
|
||||
|
||||
// Start with cleared status
|
||||
$scope.loginError = false;
|
||||
$scope.loginStatus = false;
|
||||
|
||||
// Attempt login once existing session is destroyed
|
||||
authenticationService.authenticate($scope.enteredValues)
|
||||
|
||||
// Clear and reload upon success
|
||||
.then(function loginSuccessful() {
|
||||
$scope.loginError = false;
|
||||
$scope.enteredValues = {};
|
||||
$route.reload();
|
||||
})
|
||||
@@ -123,13 +146,24 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
||||
// Reset upon failure
|
||||
['catch'](function loginFailed(error) {
|
||||
|
||||
// Flag generic error for invalid login
|
||||
if (error.type === Error.Type.INVALID_CREDENTIALS)
|
||||
$scope.loginError = true;
|
||||
|
||||
// Clear out passwords if the credentials were rejected for any reason
|
||||
if (error.type !== Error.Type.INSUFFICIENT_CREDENTIALS) {
|
||||
angular.forEach($scope.form, function clearEnteredValueIfPassword(field) {
|
||||
|
||||
// Flag generic error for invalid login
|
||||
if (error.type === Error.Type.INVALID_CREDENTIALS)
|
||||
$scope.loginError = true;
|
||||
|
||||
// Display error if anything else goes wrong
|
||||
else
|
||||
$scope.loginStatus = {
|
||||
'className' : 'error',
|
||||
'title' : 'LOGIN.DIALOG_HEADER_ERROR',
|
||||
'text' : error.message,
|
||||
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||
};
|
||||
|
||||
// Clear all visible password fields
|
||||
angular.forEach($scope.remainingFields, function clearEnteredValueIfPassword(field) {
|
||||
|
||||
// Remove entered value only if field is a password field
|
||||
if (field.type === Field.Type.PASSWORD)
|
||||
|
Reference in New Issue
Block a user