Search in sources :

Example 1 with PasswordChange

use of amu.zhcet.auth.password.PasswordChange in project zhcet-web by zhcet-amu.

the class PasswordChangeController method changePassword.

@GetMapping
public String changePassword(Model model) {
    User user = userService.getLoggedInUser().orElseThrow(UserNotFoundException::new);
    if (!user.isEmailVerified()) {
        log.warn("User not verified and tried to change the password!");
        model.addAttribute("error", "The user is not verified, and hence can't change the password");
    } else {
        if (!model.containsAttribute("password")) {
            PasswordChange passwordChange = new PasswordChange();
            model.addAttribute("password", passwordChange);
        }
        model.addAttribute("blacklist", Arrays.asList(user.getName(), user.getEmail(), user.getUserId()));
    }
    return "user/change_password";
}
Also used : UserNotFoundException(amu.zhcet.data.user.UserNotFoundException) User(amu.zhcet.data.user.User) PasswordChange(amu.zhcet.auth.password.PasswordChange) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

PasswordChange (amu.zhcet.auth.password.PasswordChange)1 User (amu.zhcet.data.user.User)1 UserNotFoundException (amu.zhcet.data.user.UserNotFoundException)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1