Skip to content
This repository was archived by the owner on Apr 22, 2022. It is now read-only.

Commit 3413c5c

Browse files
author
taleksashina
committed
restore password detailed errors
1 parent 9df1f1d commit 3413c5c

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

src/main/java/authentication/web/AuthenticationServlet.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* Error codes:
3434
* 1 - user already exists (during user registration, user with the same name or e-mail already exists)
3535
* 2 - incorrect old password (change password)
36+
* 3 - user doesn't exists (in restore password)
3637
*/
3738
public class AuthenticationServlet extends HttpServlet {
3839
/**
@@ -215,8 +216,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
215216
try {
216217
userProfile = frameworkUserManager.getUserProfile(username);
217218
if (userProfile == null) {
218-
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "User profile "
219-
+ username + " not found");
219+
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
220+
out.print("{\"code\" : \"3\", \"message\" : \"User doesn't exists\"}");
221+
return;
220222
}
221223
// change password
222224
String password = new RandomStringGenerator().generateBasic(6);

src/main/webapp/i18n/resources-locale_en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,11 @@
19341934
"value":"Incorrect old password",
19351935
"description":"change password error: incorrect old password"
19361936
},
1937+
{
1938+
"key":"_user-not-exists_",
1939+
"value":"User doesn't exists",
1940+
"description":"if user was not found by name, for example, in restore password dialog"
1941+
},
19371942

19381943

19391944
{

src/main/webapp/i18n/resources-locale_ru.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,11 @@
19321932
"value":"Неверно указан старый пароль",
19331933
"description":"change password error: incorrect old password"
19341934
},
1935+
{
1936+
"key":"_user-not-exists_",
1937+
"value":"Пользователь с указанным именем не найден",
1938+
"description":"if user was not found by name, for example, in restore password dialog"
1939+
},
19351940

19361941

19371942
{

src/main/webapp/js/login-controller.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ function LoginCtrl($scope, flash, AccountService, LoginService, ServerErrorRespo
9898
flash.success = response.data.message;
9999
}, function(response) {
100100
$scope.close('#modalRestorePassword');
101-
flash.error = ServerErrorResponse.getMessage(response.status);
101+
if (response.status==500 && response.data) {
102+
flash.error = AuthenticationErrorResponse.getMessage(parseInt(response.data.code));
103+
} else {
104+
flash.error = ServerErrorResponse.getMessage(response.status);
105+
}
102106
});
103107
};
104108

src/main/webapp/js/services/services.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ module.factory('AuthenticationErrorResponse', function(localize) {
213213
case 2:
214214
errorText = localize.getLocalizedString("_incorrect-old-password-error_");
215215
break;
216+
case 3:
217+
errorText = localize.getLocalizedString("_user-not-exists_");
218+
break;
216219
default:
217220
errorText = code;
218221
};

0 commit comments

Comments
 (0)