This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit cbfefbfa05fa15d236e7cc4a8f45713b8ae5c28e Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 28 17:47:06 2015 +0100 add ui for forgotten password --- coselmar-ui/src/main/webapp/i18n/en.js | 7 +++++ coselmar-ui/src/main/webapp/i18n/fr.js | 7 +++++ coselmar-ui/src/main/webapp/index.html | 2 +- .../src/main/webapp/js/coselmar-controllers.js | 31 +++++++++++++++++++++- .../src/main/webapp/js/coselmar-user-services.js | 18 ++++++++++++- coselmar-ui/src/main/webapp/js/coselmar.js | 6 ++++- .../src/main/webapp/views/users/newPassword.html | 30 +++++++++++++++++++++ 7 files changed, 97 insertions(+), 4 deletions(-) diff --git a/coselmar-ui/src/main/webapp/i18n/en.js b/coselmar-ui/src/main/webapp/i18n/en.js index 05c7320..91e9bdb 100644 --- a/coselmar-ui/src/main/webapp/i18n/en.js +++ b/coselmar-ui/src/main/webapp/i18n/en.js @@ -177,6 +177,7 @@ var translateEN = { <li>Client</li>\ </ul>", "user.create.client.info" : "Create new user with Client role", +"user.password.title" : "Send a new password", "user.metadata.name" : "Name", "user.metadata.firstName" : "First name", @@ -209,12 +210,17 @@ var translateEN = { "user.message.tooShortPassword" : "New password should contain at least 6 characters.", "user.message.passwordsNoMatch" : "The two new passwords don't match.", "user.message.login" : "Login :", +"user.message.forgotPassword" : "I forgot my password", +"user.message.enterMail" : "Please enter your email", +"user.message.unknownMail" : "This email does not exist.", +"user.message.newPasswordSent" : "A new password has been sent.", "user.button.add" : "Add an user", "user.button.add.client" : "Add a client", "user.button.disable" : "Disable", "user.button.enable" : "Enable", "user.button.showDisable" : "Show disable", +"user.button.newPassword" : "Send", //Referential part @@ -252,5 +258,6 @@ var translateEN = { "common.message.missingMandatoryFields" : "Some mandatory field (*) have not been filled.", "common.message.notYetAvailable" : "Not yet available.", "common.message.mandatoryFieldsInfo" : "Field with <strong><big>*</big></strong> are mandatory.", +"common.message.internalError" : "Error during process. If this problem persist, please contact application admin", } \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/i18n/fr.js b/coselmar-ui/src/main/webapp/i18n/fr.js index 690884f..fbc9b04 100644 --- a/coselmar-ui/src/main/webapp/i18n/fr.js +++ b/coselmar-ui/src/main/webapp/i18n/fr.js @@ -177,6 +177,7 @@ var translateFR = { <li>Client</li>\ </ul>", "user.create.client.info" : "Créer un nouvel utilisateur de rôle \"Client\"", +"user.password.title" : "Envoi d'un nouveau mot de passe", "user.metadata.name" : "Nom", "user.metadata.firstName" : "Prénom", @@ -209,12 +210,17 @@ var translateFR = { "user.message.tooShortPassword" : "Le nouveau mot de passe doit contenir au moins 6 caractères.", "user.message.passwordsNoMatch" : "Les deux mots de passe entrés sont différents.", "user.message.login" : "Connectez-vous :", +"user.message.forgotPassword" : "J'ai oublié mon mot de passe", +"user.message.enterMail" : "Veuillez entrer votre courriel", +"user.message.unknownMail" : "Ce courriel est inconnu.", +"user.message.newPasswordSent" : "Un nouveau mot de passe a été envoyé.", "user.button.add" : "Ajouter un utilisateur", "user.button.add.client" : "Ajouter un client", "user.button.disable" : "Désactiver", "user.button.enable" : "Activer", "user.button.showDisable" : "Montrer les désactivés", +"user.button.newPassword" : "Envoyer", //Referential part @@ -252,5 +258,6 @@ var translateFR = { "common.message.missingMandatoryFields" : "Certains champs obligatoires (*) n'ont pas été remplis.", "common.message.notYetAvailable" : "Pas encore disponible.", "common.message.mandatoryFieldsInfo" : "Les champs avec un <strong><big>*</big></strong> sont obligatoires.", +"common.message.internalError" : "Erreur durant le traitement. Si le problème persiste, veuillez contacter l'administrateur de l'application.", } \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/index.html b/coselmar-ui/src/main/webapp/index.html index 088f5bf..ffbdc16 100644 --- a/coselmar-ui/src/main/webapp/index.html +++ b/coselmar-ui/src/main/webapp/index.html @@ -111,7 +111,7 @@ <!-- Login Part --> <form class="navbar-form navbar-right" role="form" ng-if="!currentUser"> <div class="user-info"> - {{ 'user.message.login' | translate}} + {{ 'user.message.login' | translate}} (<a href="#/users/forgotPassword">{{ 'user.message.forgotPassword' | translate }}</a> ) </div> <div class="form-group"> <input type="text" placeholder="Mail" class="form-control" ng-model="loginMail"> diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 3e8033e..1c6db12 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -21,7 +21,7 @@ * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ -var coselmarControllers = angular.module('coselmarControllers', ['ui.bootstrap', 'ui.select', 'ui.bootstrap.tooltip']); +var coselmarControllers = angular.module('coselmarControllers', ['ui.bootstrap', 'ui.select', 'ui.bootstrap.tooltip', 'pascalprecht.translate']); // Controller when the main page/view loads coselmarControllers.controller("HomeCtrl", ['$scope', '$http', '$location', '$routeParams', '$locale', '$translate', 'userService', 'jwtHelper', 'coselmar-config', @@ -483,6 +483,35 @@ coselmarControllers.controller("UserViewCtrl", } ]); +coselmarControllers.controller("NewPasswordCtrl", ['$scope', '$translate', 'userService', function($scope, $translate, userService){ + + $scope.alerts = []; + + $scope.closeAlert = function(index) { + $scope.alerts.splice(index, 1); + }; + + $scope.sendPassword = function(){ + + // Call service to create a new user + if($scope.mail) { + userService.sendNewPassword($scope.mail, function() { + $scope.alerts.push({ type : 'success', msg : "user.message.newPasswordSent"}); + delete $scope.mail; + }, function(error) { + if (error.status == 404) { + $scope.alerts.push({ type : 'danger', msg : "user.message.unknownMail"}); + } else { + $scope.alerts.push({ type : 'danger', msg : "common.message.internalError"}); + } + }); + } else { + $scope.alerts.push({ type : 'danger', msg : "user.message.enterMail"}); + }; + + }; +}]); + // This directive checks two inputs have identical values. // This is used for new password check coselmarControllers.directive('identicalCheck', [function () { diff --git a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js index efd0c70..850dcd6 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js @@ -90,6 +90,22 @@ function User(resource, config){ }, }}); userResource.post(credentials, successFunction, failFunction); - } + }; + + this.sendNewPassword = function(mail, successFunction, failFunction){ + + var params = $.param({ + 'userMail' : mail + }); + + var userResource = resource(baseURL + "/password", null, { + 'post' : { + method: 'POST', + headers : { + 'Content-Type' : 'application/x-www-form-urlencoded;charset=utf-8' + }, + }}); + userResource.post(params, successFunction, failFunction); + }; }; \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/js/coselmar.js b/coselmar-ui/src/main/webapp/js/coselmar.js index eb3b393..788b3a9 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar.js +++ b/coselmar-ui/src/main/webapp/js/coselmar.js @@ -48,6 +48,10 @@ coselmarApp.config(['$routeProvider', function($routeProvider) { controller : 'NewUserCtrl', templateUrl : 'views/users/newuser.html' + }).when('/users/forgotPassword', { + controller : 'NewPasswordCtrl', + templateUrl : 'views/users/newPassword.html' + }).when('/users/:userId', { controller : 'UserViewCtrl', templateUrl : 'views/users/user.html' @@ -117,7 +121,7 @@ coselmarApp.config(function($httpProvider) { $location.path("/403"); } else if (rejection.status == 404) { - $location.path("/404"); +// $location.path("/404"); } else { $location.path("/"); diff --git a/coselmar-ui/src/main/webapp/views/users/newPassword.html b/coselmar-ui/src/main/webapp/views/users/newPassword.html new file mode 100644 index 0000000..bb6f23f --- /dev/null +++ b/coselmar-ui/src/main/webapp/views/users/newPassword.html @@ -0,0 +1,30 @@ +<div class="page-header"> + <h2> + <!-- Heading goes here --> + {{ 'user.password.title' | translate }} + </h2> +</div> + +<div class="text-center"> + <alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg | translate}}</alert> +</div> + +<div class="text-center"> + + <form name="newPasswordForm" class="form-inline" role="form" ng-submit="sendPassword()"> + <div class="form-group"> + <label class="control-label">{{ 'user.message.enterMail' | translate }}</label> + + <input type="email" class="form-control" name="mail" + placeholder="james.bond@mi6.org" ng-model="mail" required/> + </div> + + + <div class="form-group"> + <div class="float-right col-md-4"> + <input type="submit" value="{{'user.button.newPassword' | translate}}" class="btn btn-primary" /> + </div> + </div> + + </form> +</div> \ No newline at end of file -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.