Basic disabling of TFA
All checks were successful
Deploy API / deploy (ubuntu-latest, 2.44.0) (push) Successful in 55s
All checks were successful
Deploy API / deploy (ubuntu-latest, 2.44.0) (push) Successful in 55s
This commit is contained in:
parent
57d10bd9c1
commit
b95c92707b
@ -97,6 +97,17 @@ public final class UserController {
|
|||||||
return ResponseEntity.ok(userService.enableTwoFactor(input));
|
return ResponseEntity.ok(userService.enableTwoFactor(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A POST endpoint to disable TFA for a useer.
|
||||||
|
*
|
||||||
|
* @return the disabled response
|
||||||
|
*/
|
||||||
|
@PostMapping("/disable-tfa") @ResponseBody @NonNull
|
||||||
|
public ResponseEntity<Map<String, Object>> disableTwoFactor() {
|
||||||
|
userService.disableTwoFactor();
|
||||||
|
return ResponseEntity.ok(Map.of("success", true));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A POST endpoint to logout the user.
|
* A POST endpoint to logout the user.
|
||||||
*
|
*
|
||||||
|
@ -78,6 +78,15 @@ public final class User {
|
|||||||
flags |= flag.bitwise();
|
flags |= flag.bitwise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a flag from this user.
|
||||||
|
*
|
||||||
|
* @param flag the flag to remove
|
||||||
|
*/
|
||||||
|
public void removeFlag(@NonNull UserFlag flag) {
|
||||||
|
flags &= ~flag.bitwise();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this user has a given flag.
|
* Check if this user has a given flag.
|
||||||
*
|
*
|
||||||
|
@ -222,6 +222,17 @@ public final class UserService {
|
|||||||
return originalBackupCodes;
|
return originalBackupCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable two-factor auth for the
|
||||||
|
* currently authenticated user.
|
||||||
|
*/
|
||||||
|
public void disableTwoFactor() {
|
||||||
|
User user = authService.getAuthenticatedUser();
|
||||||
|
user.setTfa(null);
|
||||||
|
user.removeFlag(UserFlag.TFA_ENABLED);
|
||||||
|
userRepository.save(user);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logout the user.
|
* Logout the user.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user