use of de.symeda.sormas.backend.user.event.PasswordResetEvent in project SORMAS-Project by hzi-braunschweig.
the class StartupShutdownService method createOrUpdateDefaultUser.
private void createOrUpdateDefaultUser(Set<UserRole> userRoles, String username, String password, String firstName, String lastName) {
if (StringUtils.isAnyBlank(username, password)) {
logger.debug("Invalid user details. Will not create/update default user");
return;
}
User existingUser = userService.getByUserName(username);
if (existingUser == null) {
if (!DataHelper.isNullOrEmpty(password)) {
User newUser = MockDataGenerator.createUser(userRoles, firstName, lastName, password);
newUser.setUserName(username);
userService.persist(newUser);
userUpdateEvent.fire(new UserUpdateEvent(newUser));
}
} else if (!DataHelper.equal(existingUser.getPassword(), PasswordHelper.encodePassword(password, existingUser.getSeed()))) {
existingUser.setSeed(PasswordHelper.createPass(16));
existingUser.setPassword(PasswordHelper.encodePassword(password, existingUser.getSeed()));
userService.persist(existingUser);
passwordResetEvent.fire(new PasswordResetEvent(existingUser));
}
}
use of de.symeda.sormas.backend.user.event.PasswordResetEvent in project SORMAS-Project by hzi-braunschweig.
the class UserFacadeEjb method resetPassword.
@Override
public String resetPassword(String uuid) {
String resetPassword = userService.resetPassword(uuid);
passwordResetEvent.fire(new PasswordResetEvent(userService.getByUuid(uuid)));
return resetPassword;
}
Aggregations