password reset: show 2fa input

This commit is contained in:
Girish Ramakrishnan
2021-08-11 12:16:45 -07:00
parent 458a758ea7
commit 6ac297bac5
2 changed files with 11 additions and 6 deletions

View File

@@ -130,32 +130,33 @@ app.controller('LoginController', ['$scope', '$translate', '$http', function ($s
var data = {
resetToken: search.resetToken,
password: $scope.newPassword
password: $scope.newPassword,
totpToken: $scope.totpToken
};
function error(status) {
function error(data, status) {
console.log('error', status);
$scope.busy = false;
if (status === 401) $scope.error = 'Invalid reset token';
if (status === 401) $scope.error = data.message;
else if (status === 409) $scope.error = 'Ask your admin for an invite link first';
else $scope.error = 'Unknown error';
}
$http.post(API_ORIGIN + '/api/v1/cloudron/password_reset', data).success(function (data, status) {
if (status !== 202) return error(status);
if (status !== 202) return error(data, status);
// set token to autologin
localStorage.token = data.accessToken;
$scope.mode = 'newPasswordDone';
}).error(function (data, status) {
error(status);
error(data, status);
});
};
$scope.showPasswordReset = function () {
window.document.title = 'Password Reset';
window.document.title = 'Password Reset Request';
$scope.mode = 'passwordReset';
$scope.passwordResetIdentifier = '';
setTimeout(function () { $('#inputPasswordResetIdentifier').focus(); }, 200);