use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class AuthenticationController method signUp.
@PostMapping({ "/v3/auth/signUp", "/api/v1/auth/signUp" })
@ResponseStatus(HttpStatus.CREATED)
public StatusMessage signUp() {
JsonNode node = parseJson(JsonNode.class);
StudyParticipant participant = parseJson(node, StudyParticipant.class);
String appId = JsonUtils.asText(node, APP_ID_PROPERTY, STUDY_PROPERTY);
getMetrics().setAppId(appId);
App app = getAppOrThrowException(appId);
authenticationService.signUp(app, participant);
return new StatusMessage("Signed up.");
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class AuthenticationController method requestResetPassword.
@PostMapping({ "/v3/auth/requestResetPassword", "/api/v1/auth/requestResetPassword" })
@ResponseStatus(HttpStatus.ACCEPTED)
public StatusMessage requestResetPassword() {
SignIn signIn = parseJson(SignIn.class);
App app = appService.getApp(signIn.getAppId());
verifySupportedVersionOrThrowException(app);
authenticationService.requestResetPassword(app, false, signIn);
// Email is chosen over phone number, so if email was provided, respond as if we used it.
if (signIn.getEmail() != null) {
return new StatusMessage(EMAIL_RESET_PWD_MSG);
}
return new StatusMessage(PHONE_RESET_PWD_MSG);
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class AuthenticationController method signOutV4.
@PostMapping("/v4/auth/signOut")
public StatusMessage signOutV4() {
final UserSession session = getSessionIfItExists();
// Always set, even if we eventually decide to return an error code when there's no session
Cookie cookie = HttpUtil.makeSessionCookie("", 0);
response().addCookie(cookie);
response().setHeader(CLEAR_SITE_DATA_HEADER, CLEAR_SITE_DATA_VALUE);
if (session != null) {
authenticationService.signOut(session);
} else {
throw new BadRequestException("Not signed in");
}
return new StatusMessage("Signed out.");
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class AuthenticationController method resendPhoneVerification.
@PostMapping("/v3/auth/resendPhoneVerification")
@ResponseStatus(HttpStatus.ACCEPTED)
public StatusMessage resendPhoneVerification() {
AccountId accountId = parseJson(AccountId.class);
// Must be here to get the correct exception if app property is missing
getAppOrThrowException(accountId.getUnguardedAccountId().getAppId());
authenticationService.resendVerification(ChannelType.PHONE, accountId);
return new StatusMessage(PHONE_VERIFY_REQUEST_MSG);
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantControllerTest method createCustomActivityEvent.
@Test
public void createCustomActivityEvent() throws Exception {
CustomActivityEventRequest request = new CustomActivityEventRequest.Builder().withEventKey("eventKey").withTimestamp(TIMESTAMP).build();
mockRequestBody(mockRequest, request);
StatusMessage retValue = controller.createCustomActivityEvent(TEST_USER_ID);
assertEquals(retValue.getMessage(), "Event recorded.");
verify(mockParticipantService).createCustomActivityEvent(eq(app), eq(TEST_USER_ID), eventRequestCaptor.capture());
CustomActivityEventRequest captured = eventRequestCaptor.getValue();
assertEquals(captured.getEventKey(), "eventKey");
assertEquals(captured.getTimestamp(), TIMESTAMP);
}
Aggregations