Search in sources :

Example 1 with TwoFactorConfirmationException

use of jetbrains.buildServer.serverSide.auth.impl.TwoFactorConfirmationException in project teamcity-rest by JetBrains.

the class TwoFactorRequest method confirmTwoFactor.

@POST
@Path("/confirm")
@ApiOperation(value = "Confirm 2FA secret key", nickname = "confirm2FA")
public void confirmTwoFactor(@QueryParam("uuid") String uuid, @QueryParam("password") int password, @Context HttpServletRequest request) {
    if (uuid == null) {
        throw new BadRequestException("Missing parameter 'uuid'");
    }
    try {
        myKeysUpdater.confirmCredentials(myUserFinder.getCurrentUser(), UUID.fromString(uuid), password);
        // TODO: attempt to prevent instant kick after enabled 2FA without context request
        TwoFactorAuthUtil.setTwoFactorCompletion(request);
    } catch (TwoFactorConfirmationException e) {
        throw new BadRequestException(e.getMessage());
    }
}
Also used : TwoFactorConfirmationException(jetbrains.buildServer.serverSide.auth.impl.TwoFactorConfirmationException) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)1 TwoFactorConfirmationException (jetbrains.buildServer.serverSide.auth.impl.TwoFactorConfirmationException)1