mirror of
https://github.com/sismics/docs.git
synced 2025-12-22 14:11:39 +00:00
#161: password recovery by email (wip)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Login controller.
|
||||
*/
|
||||
angular.module('docs').controller('Login', function(Restangular, $scope, $rootScope, $state, $dialog, User, $translate) {
|
||||
angular.module('docs').controller('Login', function(Restangular, $scope, $rootScope, $state, $dialog, User, $translate, $uibModal) {
|
||||
$scope.codeRequired = false;
|
||||
|
||||
// Get the app configuration
|
||||
@@ -28,7 +28,7 @@ angular.module('docs').controller('Login', function(Restangular, $scope, $rootSc
|
||||
});
|
||||
$state.go('document.default');
|
||||
}, function(data) {
|
||||
if (data.data.type == 'ValidationCodeRequired') {
|
||||
if (data.data.type === 'ValidationCodeRequired') {
|
||||
// A TOTP validation code is required to login
|
||||
$scope.codeRequired = true;
|
||||
} else {
|
||||
@@ -40,4 +40,31 @@ angular.module('docs').controller('Login', function(Restangular, $scope, $rootSc
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Password lost
|
||||
$scope.openPasswordLost = function () {
|
||||
$uibModal.open({
|
||||
templateUrl: 'partial/docs/passwordlost.html',
|
||||
controller: 'LoginModalPasswordLost'
|
||||
}).result.then(function (email) {
|
||||
if (name === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send a password lost email
|
||||
Restangular.one('user').post('passwordLost', {
|
||||
email: email
|
||||
}).then(function () {
|
||||
var title = $translate.instant('login.password_lost_sent_title');
|
||||
var msg = $translate.instant('login.password_lost_sent_message', { email: email });
|
||||
var btns = [{result: 'ok', label: $translate.instant('ok'), cssClass: 'btn-primary'}];
|
||||
$dialog.messageBox(title, msg, btns);
|
||||
}, function () {
|
||||
var title = $translate.instant('login.password_lost_error_title');
|
||||
var msg = $translate.instant('login.password_lost_error_message', { email: email });
|
||||
var btns = [{result: 'ok', label: $translate.instant('ok'), cssClass: 'btn-primary'}];
|
||||
$dialog.messageBox(title, msg, btns);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Login modal password lost controller.
|
||||
*/
|
||||
angular.module('docs').controller('LoginModalPasswordLost', function ($scope, $uibModalInstance) {
|
||||
$scope.email = '';
|
||||
$scope.close = function(name) {
|
||||
$uibModalInstance.close(name);
|
||||
}
|
||||
});
|
||||
@@ -48,6 +48,7 @@
|
||||
<script src="app/docs/app.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/Main.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/Login.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/LoginModalPasswordLost.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/Navigation.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/Footer.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/document/Document.js" type="text/javascript"></script>
|
||||
|
||||
@@ -9,7 +9,17 @@
|
||||
"submit": "Sign in",
|
||||
"login_as_guest": "Login as guest",
|
||||
"login_failed_title": "Login failed",
|
||||
"login_failed_message": "Username or password invalid"
|
||||
"login_failed_message": "Username or password invalid",
|
||||
"password_lost_btn": "Password lost?",
|
||||
"password_lost_sent_title": "Password reset email sent",
|
||||
"password_lost_sent_message": "An email has been sent to <strong>{{ email }}</strong> to reset your password",
|
||||
"password_lost_error_title": "Password reset error",
|
||||
"password_lost_error_message": "Unable to send a password reset email, please contact your administrator for a manual reset"
|
||||
},
|
||||
"passwordlost": {
|
||||
"title": "Password lost",
|
||||
"message": "Please enter your email address to receive a password reset link",
|
||||
"submit": "Reset my password"
|
||||
},
|
||||
"index": {
|
||||
"toggle_navigation": "Toggle navigation",
|
||||
|
||||
@@ -44,7 +44,11 @@
|
||||
<span class="glyphicon glyphicon-ok"></span> {{ 'login.submit' | translate }}
|
||||
</button>
|
||||
|
||||
<p class="text-center lead" ng-if="app.guest_login"> </p>
|
||||
<div class="text-center well-sm btn-password-lost">
|
||||
<a href ng-click="openPasswordLost()">{{ 'login.password_lost_btn' | translate }}</a>
|
||||
</div>
|
||||
|
||||
<p class="text-center" ng-if="app.guest_login"> </p>
|
||||
|
||||
<button type="submit" class="btn btn-default btn-block" ng-if="app.guest_login" ng-click="loginAsGuest()">
|
||||
<span class="glyphicon glyphicon-user"></span> {{ 'login.login_as_guest' | translate }}
|
||||
|
||||
17
docs-web/src/main/webapp/src/partial/docs/passwordlost.html
Normal file
17
docs-web/src/main/webapp/src/partial/docs/passwordlost.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<form name="form">
|
||||
<div class="modal-header">
|
||||
<h3>{{ 'passwordlost.title' | translate }}</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
<label for="share-result">{{ 'passwordlost.message' | translate }}</label>
|
||||
<input name="email" class="form-control" type="email" required id="share-result" ng-model="email" />
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button ng-click="close(email)" class="btn btn-primary" ng-disabled="!form.$valid">
|
||||
<span class="glyphicon glyphicon-envelope"></span> {{ 'passwordlost.submit' | translate }}
|
||||
</button>
|
||||
<button ng-click="close(null)" class="btn btn-default">{{ 'cancel' | translate }}</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -343,6 +343,10 @@ input[readonly].share-link {
|
||||
.help-block, .checkbox {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-password-lost {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Styling for the ngProgress itself */
|
||||
|
||||
Reference in New Issue
Block a user