Search in sources :

Example 1 with PasswordResetEvent

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));
    }
}
Also used : UserUpdateEvent(de.symeda.sormas.backend.user.event.UserUpdateEvent) User(de.symeda.sormas.backend.user.User) PasswordResetEvent(de.symeda.sormas.backend.user.event.PasswordResetEvent)

Example 2 with PasswordResetEvent

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;
}
Also used : PasswordResetEvent(de.symeda.sormas.backend.user.event.PasswordResetEvent)

Aggregations

PasswordResetEvent (de.symeda.sormas.backend.user.event.PasswordResetEvent)2 User (de.symeda.sormas.backend.user.User)1 UserUpdateEvent (de.symeda.sormas.backend.user.event.UserUpdateEvent)1