Search in sources :

Example 6 with UserNotFoundException

use of amu.zhcet.data.user.UserNotFoundException in project zhcet-web by zhcet-amu.

the class TwoFAService method enable2FA.

/**
 * Unconditionally enables 2 Factor Authentication for the user if OTP secret is already present
 */
void enable2FA() {
    User user = userService.getLoggedInUser().orElseThrow(UserNotFoundException::new);
    if (user.getTotpSecret() == null)
        return;
    user.setUsing2fa(true);
    userService.save(user);
}
Also used : UserNotFoundException(amu.zhcet.data.user.UserNotFoundException) User(amu.zhcet.data.user.User)

Example 7 with UserNotFoundException

use of amu.zhcet.data.user.UserNotFoundException in project zhcet-web by zhcet-amu.

the class EmailUnsubscribeController method unsubscribe.

@ResponseBody
@GetMapping("/login/unsubscribe")
public String unsubscribe(@RequestParam String email, @RequestParam String conf) {
    User user = userService.getUserByEmail(email).orElseThrow(UserNotFoundException::new);
    if (!SecurityUtils.hashMatches(email, conf))
        return "Invalid Entry";
    userService.unsubscribeEmail(user, true);
    return "Unsubscribed";
}
Also used : UserNotFoundException(amu.zhcet.data.user.UserNotFoundException) User(amu.zhcet.data.user.User) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

User (amu.zhcet.data.user.User)7 UserNotFoundException (amu.zhcet.data.user.UserNotFoundException)7 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 PasswordChange (amu.zhcet.auth.password.PasswordChange)1 PasswordValidationException (amu.zhcet.auth.password.PasswordValidationException)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1