Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UFAL/Create verification object after the email is sent #786

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,8 @@ public ResponseEntity sendEmail(HttpServletRequest request, HttpServletResponse
log.error("Cannot load the `dspace.ui.url` property from the cfg.");
throw new RuntimeException("Cannot load the `dspace.ui.url` property from the cfg.");
}
// Generate token and create ClarinVerificationToken record with the token and user email.
// Generate token
String verificationToken = Utils.generateHexKey();
clarinVerificationToken.setEmail(email);
clarinVerificationToken.setToken(verificationToken);
clarinVerificationTokenService.update(context, clarinVerificationToken);
context.commit();

// Compose the url with the verification token. The user will be redirected to the UI.
String autoregistrationURL = uiUrl + "/login/autoregistration?verification-token=" + verificationToken;
Expand All @@ -121,6 +117,13 @@ public ResponseEntity sendEmail(HttpServletRequest request, HttpServletResponse
return null;
}

// Add ClarinVerificationToken record with the token and user email to the database only if the
// email was successfully send.
clarinVerificationToken.setEmail(email);
clarinVerificationToken.setToken(verificationToken);
clarinVerificationTokenService.update(context, clarinVerificationToken);
context.commit();

return ResponseEntity.ok().build();
}

Expand Down
Loading