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);
}
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";
}
Aggregations