Repository: syncope Updated Branches: refs/heads/2_0_X eea3e493f -> 13caa7a8c
[SYNCOPE-970] restore default language settings on logout and page refresh Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/13caa7a8 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/13caa7a8 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/13caa7a8 Branch: refs/heads/2_0_X Commit: 13caa7a8cd529c517a72f9aa2fbfcd1ac27b2bc0 Parents: eea3e49 Author: Matteo Di Carlo <[email protected]> Authored: Fri Nov 18 12:56:12 2016 +0100 Committer: Matteo Di Carlo <[email protected]> Committed: Fri Nov 18 12:56:12 2016 +0100 ---------------------------------------------------------------------- .../resources/META-INF/resources/app/index.html | 1 - .../resources/META-INF/resources/app/js/app.js | 4 +-- .../app/js/controllers/LoginController.js | 19 +++-------- .../app/js/controllers/TailController.js | 29 ----------------- .../app/js/controllers/UserController.js | 33 +++++++++++++++++--- .../META-INF/resources/app/views/editUser.html | 2 +- .../resources/app/views/passwordreset.html | 4 +-- .../META-INF/resources/app/views/self.html | 2 +- .../META-INF/resources/app/views/success.html | 2 +- 9 files changed, 39 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/13caa7a8/client/enduser/src/main/resources/META-INF/resources/app/index.html ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/index.html b/client/enduser/src/main/resources/META-INF/resources/app/index.html index 55b34a5..30f155b 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/index.html +++ b/client/enduser/src/main/resources/META-INF/resources/app/index.html @@ -98,7 +98,6 @@ under the License. <script src="js/controllers/HomeController.js"></script> <script src="js/controllers/LoginController.js"></script> <script src="js/controllers/UserController.js"></script> - <script src="js/controllers/TailController.js"></script> <!--directives--> <script src="js/directives/dynamicPlainAttribute.js"></script> <script src="js/directives/dynamicDerivedAttribute.js"></script> http://git-wip-us.apache.org/repos/asf/syncope/blob/13caa7a8/client/enduser/src/main/resources/META-INF/resources/app/js/app.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/app.js b/client/enduser/src/main/resources/META-INF/resources/app/js/app.js index 12c814c..efdf8ed 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/app.js +++ b/client/enduser/src/main/resources/META-INF/resources/app/js/app.js @@ -53,8 +53,8 @@ app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$translate $translateProvider.useLoader('$translatePartialLoader', { urlTemplate: 'languages/{lang}/{part}.json' }) - .preferredLanguage('en') - .useCookieStorage(); + .preferredLanguage('en'); +// .useCookieStorage(); // route configuration $stateProvider http://git-wip-us.apache.org/repos/asf/syncope/blob/13caa7a8/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/LoginController.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/LoginController.js b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/LoginController.js index 75d41a6..af0bfdb 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/LoginController.js +++ b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/LoginController.js @@ -18,25 +18,16 @@ */ 'use strict'; -angular.module("login").controller("LoginController", ['$scope', '$http', '$location', - 'AuthService', '$translate', '$translatePartialLoader', function ($scope, $http, - $location, AuthService, $translate) { +angular.module("login").controller("LoginController", ['$scope', '$http', '$location', 'AuthService', + function ($scope, $http, $location, AuthService) { $scope.credentials = { username: '', password: '', errorMessage: '' }; - $scope.languages = { - availableLanguages: [ - {id: '1', name: 'Italiano', code: 'it'}, - {id: '2', name: 'English', code: 'en'}, - {id: '3', name: 'Deutsch', code: 'de'} - ], - selectedLanguage: {id: '2', name: 'English', code: 'en'} - }; - $scope.login = function (credentials) { + $scope.login = function (credentials) { AuthService.login($scope.credentials).then(function (user) { console.info("Login success for: ", user); // reset error message @@ -55,6 +46,7 @@ angular.module("login").controller("LoginController", ['$scope', '$http', '$loca $scope.showError($scope.credentials.errorMessage, $scope.notification); }); }; + $scope.logout = function () { AuthService.logout().then(function (response) { console.info("Logout successfully"); @@ -91,7 +83,4 @@ angular.module("login").controller("LoginController", ['$scope', '$http', '$loca console.debug("schemaAPI response: ", data); }); }; - $scope.switchLanguage = function () { - $translate.use($scope.languages.selectedLanguage.code); - }; }]); http://git-wip-us.apache.org/repos/asf/syncope/blob/13caa7a8/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/TailController.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/TailController.js b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/TailController.js deleted file mode 100644 index fe880a3..0000000 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/TailController.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -'use strict'; - -angular.module("self") - .controller("TailController", ['$scope', '$rootScope', '$location', - function ($scope, $rootScope, $location) { - $scope.redirect = function () { - $location.path('/self'); - $rootScope.endReached = false; - }; - }]); http://git-wip-us.apache.org/repos/asf/syncope/blob/13caa7a8/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js index 2366311..45f038b 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js +++ b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js @@ -23,9 +23,9 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$location', '$compile', "$state", 'AuthService', 'UserSelfService', 'SchemaService', 'RealmService', 'ResourceService', 'SecurityQuestionService', - 'GroupService', 'AnyService', 'UserUtil', 'GenericUtil', "ValidationExecutor", + 'GroupService', 'AnyService', 'UserUtil', 'GenericUtil', 'ValidationExecutor', '$translate', function ($scope, $rootScope, $location, $compile, $state, AuthService, UserSelfService, SchemaService, RealmService, - ResourceService, SecurityQuestionService, GroupService, AnyService, UserUtil, GenericUtil, ValidationExecutor) { + ResourceService, SecurityQuestionService, GroupService, AnyService, UserUtil, GenericUtil, ValidationExecutor, $translate) { $scope.user = {}; $scope.confirmPassword = { @@ -244,11 +244,11 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l $scope.user = UserUtil.getUnwrappedUser(response); $scope.user.password = undefined; - + $scope.initialSecurityQuestion = $scope.user.securityQuestion; // initialize already assigned resources $scope.dynamicForm.selectedResources = $scope.user.resources; - + // initialize already assigned groups -- keeping the same structure of groups for (var index in $scope.user.memberships) { $scope.dynamicForm.selectedGroups.push( @@ -267,7 +267,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l $scope.$emit("groupAdded", $scope.user.memberships[index].groupName); } if ($scope.user.mustChangePassword) { - $location.path('/mustchangepassword') + $location.path('/mustchangepassword'); } else { initProperties(); } @@ -439,6 +439,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l console.info("User " + $scope.user.username); $rootScope.currentUser = $scope.user.username; $rootScope.currentOp = "PASSWORD_UPDATED"; + $translate.use($scope.languages.selectedLanguage.code); $state.go('success'); }, function (response) { var errorMessage; @@ -467,6 +468,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l if (user && user.password && token) { UserSelfService.confirmPasswordReset({"newPassword": user.password, "token": token}).then(function (data) { $scope.showSuccess(data, $scope.notification); + $translate.use($scope.languages.selectedLanguage.code); $location.path('/self'); }, function (response) { var errorMessage; @@ -510,9 +512,23 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l } }; + $scope.languages = { + availableLanguages: [ + {id: '1', name: 'Italiano', code: 'it'}, + {id: '2', name: 'English', code: 'en'}, + {id: '3', name: 'Deutsch', code: 'de'} + ], + selectedLanguage: {id: '2', name: 'English', code: 'en'} + }; + + $scope.switchLanguage = function () { + $translate.use($scope.languages.selectedLanguage.code); + }; + $scope.logout = function (message) { AuthService.logout().then(function (response) { console.info("Logout successfully"); + $translate.use($scope.languages.selectedLanguage.code); $rootScope.endReached = false; $location.path('/self'); if (message) { @@ -523,6 +539,13 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l }); }; + $scope.redirect = function () { + console.log("$scope.languages.selectedLanguage.code", $scope.languages.selectedLanguage.code); + $translate.use($scope.languages.selectedLanguage.code); + $location.path('/self'); + $rootScope.endReached = false; + }; + $scope.finish = function (message) { console.info("finish"); if ($scope.createMode) { http://git-wip-us.apache.org/repos/asf/syncope/blob/13caa7a8/client/enduser/src/main/resources/META-INF/resources/app/views/editUser.html ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/views/editUser.html b/client/enduser/src/main/resources/META-INF/resources/app/views/editUser.html index 8ce34fe..aee0509 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/views/editUser.html +++ b/client/enduser/src/main/resources/META-INF/resources/app/views/editUser.html @@ -31,7 +31,7 @@ under the License. <div class="row"> <div growl reference="2" inline="true"></div> <div id="status-buttons" class="btn-group btn-breadcrumb"> - <a href="#/self" class="btn btn-default" ng-show="createMode"><i class="glyphicon glyphicon-home"></i></a> + <a href="#/self" class="btn btn-default" ng-show="createMode" ng-click="logout()"><i class="glyphicon glyphicon-home"></i></a> <a id="logout" class="btn btn-default" ng-show="!createMode" ng-click="logout()"><i class="glyphicon glyphicon-off"style="color:red"></i></a> <!--add class breadcrumb-disabled-link to buttons to prevent click--> <a ng-repeat="(key, value) in wizard" ui-sref-active="active" ui-sref=".{{key}}" class="btn btn-default" http://git-wip-us.apache.org/repos/asf/syncope/blob/13caa7a8/client/enduser/src/main/resources/META-INF/resources/app/views/passwordreset.html ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/views/passwordreset.html b/client/enduser/src/main/resources/META-INF/resources/app/views/passwordreset.html index 3bb21c3..6c0f8e1 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/views/passwordreset.html +++ b/client/enduser/src/main/resources/META-INF/resources/app/views/passwordreset.html @@ -29,7 +29,7 @@ under the License. <div class="row"> <div id="status-buttons" class="btn-group btn-breadcrumb"> - <a href="#/self" class="btn btn-default"><i class="glyphicon glyphicon-home"></i></a> + <a href="#/self" class="btn btn-default" ng-click="logout()"><i class="glyphicon glyphicon-home"></i></a> <!--add class breadcrumb-disabled-link to buttons to prevent click--> <a ui-sref-active="active" class="btn btn-default">{{'USERDETAILS'| translate}}</a> </div> @@ -63,7 +63,7 @@ under the License. </div> <button id="resetpassword" type="submit" class="btn btn-default pull-right">{{'SUBMIT'| translate}}</button> <div class="pull-left"> - <a id="cancel" href="#/self" class="btn btn-danger">{{'CANCEL'| translate}}</a> + <a id="cancel" href="#/self" class="btn btn-danger" ng-click="logout()">{{'CANCEL'| translate}}</a> </div> </div> </div> http://git-wip-us.apache.org/repos/asf/syncope/blob/13caa7a8/client/enduser/src/main/resources/META-INF/resources/app/views/self.html ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/views/self.html b/client/enduser/src/main/resources/META-INF/resources/app/views/self.html index 90cf216..eeb9266 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/views/self.html +++ b/client/enduser/src/main/resources/META-INF/resources/app/views/self.html @@ -41,7 +41,7 @@ under the License. <input type="password" class="form-control" id="login-password" placeholder="{{'PASSWORD_PLACEHOLDER'| translate}}" ng-required ng-model="credentials.password"> </div> - <div class="form-group"> + <div class="form-group" ng-controller="UserController"> <select ng-change="switchLanguage()" id="language" style="width: 100%" class="btn dropdown-toggle btn-default" ng-options="language.name for language in languages.availableLanguages track by language.id" ng-model="languages.selectedLanguage"></select> http://git-wip-us.apache.org/repos/asf/syncope/blob/13caa7a8/client/enduser/src/main/resources/META-INF/resources/app/views/success.html ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/views/success.html b/client/enduser/src/main/resources/META-INF/resources/app/views/success.html index 994ad1b..1be0c9a 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/views/success.html +++ b/client/enduser/src/main/resources/META-INF/resources/app/views/success.html @@ -20,7 +20,7 @@ under the License. <div ng-cloak class="container"> <div class="login-container" style="box-sizing: border-box; "> <div id="form-container" class="col-md-6 col-md-offset-3" style="box-sizing: border-box; background-color: #F7F7F7;"> - <div ng-controller="TailController"> + <div ng-controller="UserController"> <div class="page-header" style="text-align: left; font-weight: 700;"> <span>{{'USER'| translate}} <b> {{currentUser}}</b> {{currentOp| translate}}</span> </div>
