@Validated
@Transactional(propagation=SUPPORTS,
readOnly=true)
public abstract class LemonService<U extends AbstractUser<U,ID>,ID extends java.io.Serializable>
extends java.lang.Object
Constructor and Description |
---|
LemonService() |
Modifier and Type | Method and Description |
---|---|
void |
afterApplicationReady(org.springframework.boot.context.event.ApplicationReadyEvent event)
This method is called after the application is ready.
|
void |
changeEmail(ID userId,
@Valid @NotBlank java.lang.String changeEmailCode)
Change the email.
|
java.lang.String |
changePassword(U user,
@Valid ChangePasswordForm changePasswordForm)
Changes the password.
|
protected U |
createAdminUser()
Creates the initial Admin user.
|
void |
createLemonService(LemonProperties properties,
org.springframework.security.crypto.password.PasswordEncoder passwordEncoder,
MailSender<?> mailSender,
AbstractUserRepository<U,ID> userRepository,
org.springframework.security.core.userdetails.UserDetailsService userDetailsService,
JwtService jwtService) |
java.lang.String |
fetchNewToken(java.util.Optional<java.lang.Long> expirationMillis,
java.util.Optional<java.lang.String> optionalUsername)
Fetches a new token - for session scrolling etc.
|
U |
fetchUserByEmail(@Valid @Email @NotBlank java.lang.String email)
Fetches a user by email
|
void |
fillAdditionalFields(java.lang.String clientId,
U user,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Extracts additional fields, e.g.
|
void |
forgotPassword(@Valid @Email @NotBlank java.lang.String email)
Forgot password.
|
java.util.Map<java.lang.String,java.lang.Object> |
getContext(java.util.Optional<java.lang.Long> expirationMillis,
javax.servlet.http.HttpServletResponse response)
Returns the context data to be sent to the client,
i.e.
|
boolean |
getOAuth2AccountVerified(java.lang.String registrationId,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Checks if the account at the OAuth2 provider is verified
|
java.lang.String |
getOAuth2Email(java.lang.String registrationId,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Extracts the email id from user attributes received from OAuth2 provider, e.g.
|
protected void |
initUser(U user)
Initializes the user based on the input data,
e.g.
|
protected void |
mailChangeEmailLink(U user)
Mails the change-email verification link to the user.
|
protected void |
mailChangeEmailLink(U user,
java.lang.String changeEmailLink)
Mails the change-email verification link to the user.
|
void |
mailForgotPasswordLink(U user)
Mails the forgot password link.
|
void |
mailForgotPasswordLink(U user,
java.lang.String forgotPasswordLink)
Mails the forgot password link.
|
protected void |
makeUnverified(U user)
Makes a user unverified
|
abstract U |
newUser()
Creates a new user object.
|
void |
onStartup()
Creates the initial Admin user, if not found.
|
U |
processUser(U user)
Returns a non-null, processed user for the client.
|
void |
requestEmailChange(U user,
U updatedUser)
Requests for email change.
|
void |
resendVerificationMail(U user)
Resends verification mail to the user.
|
void |
resetPassword(@Valid @NotBlank java.lang.String forgotPasswordCode,
@Valid java.lang.String newPassword)
Resets the password.
|
void |
save(U user)
Saves the user
|
protected void |
sendVerificationMail(U user)
Sends verification mail to a unverified user.
|
protected void |
sendVerificationMail(U user,
java.lang.String verifyLink)
Sends verification mail to a unverified user.
|
void |
signup(U user)
Signs up a user.
|
UserDto<ID> |
updateUser(U user,
U updatedUser)
Updates a user with the given data.
|
protected void |
updateUserFields(U user,
U updatedUser,
UserDto<ID> currentUser)
Updates the fields of the users.
|
void |
verifyUser(ID userId,
java.lang.String verificationCode)
Verifies the email id of current-user
|
@Autowired public void createLemonService(LemonProperties properties, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder, MailSender<?> mailSender, AbstractUserRepository<U,ID> userRepository, org.springframework.security.core.userdetails.UserDetailsService userDetailsService, JwtService jwtService)
@EventListener public void afterApplicationReady(org.springframework.boot.context.event.ApplicationReadyEvent event)
event
- @Transactional(propagation=REQUIRED, readOnly=false) public void onStartup()
protected U createAdminUser()
public abstract U newUser()
protected User newUser() { return new User(); }
public java.util.Map<java.lang.String,java.lang.Object> getContext(java.util.Optional<java.lang.Long> expirationMillis, javax.servlet.http.HttpServletResponse response)
reCaptchaSiteKey
and all the properties
prefixed with lemon.shared
.
To send custom properties, put those in your application
properties in the format lemon.shared.fooBar.
If a user is logged in, it also returns the user data
and a new authorization token. If expirationMillis is not provided,
the expiration of the new token is set to the default.
Override this method if needed.@Validated(value=AbstractUser.SignUpValidation.class) @Transactional(propagation=REQUIRED, readOnly=false) public void signup(@Valid U user)
protected void initUser(U user)
protected void makeUnverified(U user)
protected void sendVerificationMail(U user)
protected void sendVerificationMail(U user, java.lang.String verifyLink)
public void resendVerificationMail(U user)
public U fetchUserByEmail(@Valid @Email @NotBlank @Valid @Email @NotBlank java.lang.String email)
@Transactional(propagation=REQUIRED, readOnly=false) public void verifyUser(ID userId, java.lang.String verificationCode)
@Transactional(propagation=REQUIRED, readOnly=false) public void forgotPassword(@Valid @Email @NotBlank @Valid @Email @NotBlank java.lang.String email)
public void mailForgotPasswordLink(U user)
user
- public void mailForgotPasswordLink(U user, java.lang.String forgotPasswordLink)
@Transactional(propagation=REQUIRED, readOnly=false) public void resetPassword(@Valid @NotBlank @Valid @NotBlank java.lang.String forgotPasswordCode, @Valid @Valid java.lang.String newPassword)
@Validated(value=AbstractUser.UpdateValidation.class) @Transactional(propagation=REQUIRED, readOnly=false) public UserDto<ID> updateUser(U user, @Valid U updatedUser)
@Transactional(propagation=REQUIRED, readOnly=false) public java.lang.String changePassword(U user, @Valid @Valid ChangePasswordForm changePasswordForm)
protected void updateUserFields(U user, U updatedUser, UserDto<ID> currentUser)
@Validated(value=AbstractUser.ChangeEmailValidation.class) @Transactional(propagation=REQUIRED, readOnly=false) public void requestEmailChange(U user, @Valid U updatedUser)
protected void mailChangeEmailLink(U user)
protected void mailChangeEmailLink(U user, java.lang.String changeEmailLink)
@PreAuthorize(value="isAuthenticated()") @Transactional(propagation=REQUIRED, readOnly=false) public void changeEmail(ID userId, @Valid @NotBlank @Valid @NotBlank java.lang.String changeEmailCode)
public java.lang.String getOAuth2Email(java.lang.String registrationId, java.util.Map<java.lang.String,java.lang.Object> attributes)
public void fillAdditionalFields(java.lang.String clientId, U user, java.util.Map<java.lang.String,java.lang.Object> attributes)
public boolean getOAuth2AccountVerified(java.lang.String registrationId, java.util.Map<java.lang.String,java.lang.Object> attributes)
@PreAuthorize(value="isAuthenticated()") public java.lang.String fetchNewToken(java.util.Optional<java.lang.Long> expirationMillis, java.util.Optional<java.lang.String> optionalUsername)
@Transactional(propagation=REQUIRED, readOnly=false) public void save(U user)