Bug fix for forgot password error "user not found". During reset password, the user is not logged in and hence the permissions can not be applied during repository findByEmail
This commit is contained in:
parent
da8185f650
commit
4eab663c8e
|
|
@ -50,7 +50,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import static com.appsmith.server.acl.AclPermission.MANAGE_APPLICATIONS;
|
import static com.appsmith.server.acl.AclPermission.MANAGE_APPLICATIONS;
|
||||||
import static com.appsmith.server.acl.AclPermission.MANAGE_ORGANIZATIONS;
|
import static com.appsmith.server.acl.AclPermission.MANAGE_ORGANIZATIONS;
|
||||||
import static com.appsmith.server.acl.AclPermission.MANAGE_USERS;
|
import static com.appsmith.server.acl.AclPermission.MANAGE_USERS;
|
||||||
import static com.appsmith.server.acl.AclPermission.RESET_PASSWORD_USERS;
|
|
||||||
import static com.appsmith.server.acl.AclPermission.USER_MANAGE_ORGANIZATIONS;
|
import static com.appsmith.server.acl.AclPermission.USER_MANAGE_ORGANIZATIONS;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
@ -178,7 +177,7 @@ public class UserServiceImpl extends BaseService<UserRepository, User, String> i
|
||||||
log.debug("Password reset Token: {} for email: {}", token, email);
|
log.debug("Password reset Token: {} for email: {}", token, email);
|
||||||
|
|
||||||
// Check if the user exists in our DB. If not, we will not send a password reset link to the user
|
// Check if the user exists in our DB. If not, we will not send a password reset link to the user
|
||||||
Mono<User> userMono = repository.findByEmail(email, RESET_PASSWORD_USERS)
|
Mono<User> userMono = repository.findByEmail(email)
|
||||||
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.USER, email)));
|
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.USER, email)));
|
||||||
|
|
||||||
// Generate the password reset link for the user
|
// Generate the password reset link for the user
|
||||||
|
|
@ -238,7 +237,7 @@ public class UserServiceImpl extends BaseService<UserRepository, User, String> i
|
||||||
}
|
}
|
||||||
|
|
||||||
return repository
|
return repository
|
||||||
.findByEmail(email, RESET_PASSWORD_USERS)
|
.findByEmail(email)
|
||||||
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, "user", email)))
|
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, "user", email)))
|
||||||
.map(user -> {
|
.map(user -> {
|
||||||
user.setPasswordResetInitiated(true);
|
user.setPasswordResetInitiated(true);
|
||||||
|
|
@ -262,7 +261,7 @@ public class UserServiceImpl extends BaseService<UserRepository, User, String> i
|
||||||
public Mono<Boolean> resetPasswordAfterForgotPassword(String token, User user) {
|
public Mono<Boolean> resetPasswordAfterForgotPassword(String token, User user) {
|
||||||
|
|
||||||
return repository
|
return repository
|
||||||
.findByEmail(user.getEmail(), RESET_PASSWORD_USERS)
|
.findByEmail(user.getEmail())
|
||||||
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, "user", user.getEmail())))
|
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, "user", user.getEmail())))
|
||||||
.flatMap(userFromDb -> {
|
.flatMap(userFromDb -> {
|
||||||
if (!userFromDb.getPasswordResetInitiated()) {
|
if (!userFromDb.getPasswordResetInitiated()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user