Class BroadleafLoginController
java.lang.Object
org.broadleafcommerce.common.web.controller.BroadleafAbstractController
org.broadleafcommerce.core.web.controller.account.BroadleafLoginController
public class BroadleafLoginController
extends org.broadleafcommerce.common.web.controller.BroadleafAbstractController
The controller responsible for login and login related activities including
forgot username, forgot password, and reset password.
The actual login processing is done via Spring Security.
- Author:
- apazzolini, bpolster
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected org.broadleafcommerce.profile.core.service.CustomerServiceprotected static Stringprotected static Stringprotected static Stringprotected static Stringprotected static Stringprotected org.broadleafcommerce.profile.web.core.service.login.LoginServiceprotected static Stringprotected static Stringprotected static Stringprotected static Stringprotected org.broadleafcommerce.profile.core.service.validator.ResetPasswordValidatorprotected static String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbuildRedirectToLoginWithMessage(String message) By default, redirects to the login page with a message.forcedPasswordChange(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) forgotPassword(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Redirects to te forgot password view.forgotUsername(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Returns the forgot username view.View user is directed to if they try to access the resetPasswordForm with an invalid token.getResetPasswordPort(jakarta.servlet.http.HttpServletRequest request, String scheme) getResetPasswordScheme(jakarta.servlet.http.HttpServletRequest request) View that a user is sent to after a successful reset password operations.getResetPasswordUrl(jakarta.servlet.http.HttpServletRequest request) initResetPasswordForm(jakarta.servlet.http.HttpServletRequest request) Initializes the reset password by ensuring that the passed in token URL parameter initializes the hidden form field.login(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Redirects to the login view.processForcedPasswordChange(String username, jakarta.servlet.http.HttpServletRequest request, org.springframework.ui.Model model) processForgotPassword(String username, jakarta.servlet.http.HttpServletRequest request, org.springframework.ui.Model model) Looks up the passed in username and sends an email to the address on file with a reset password token.processForgotUsername(String email, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Looks up an account by email address and if found, sends an email with the associated username.processResetPassword(ResetPasswordForm resetPasswordForm, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.springframework.validation.BindingResult errors) Processes the reset password token and allows the user to change their password.resetPassword(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Displays the reset password view.Methods inherited from class org.broadleafcommerce.common.web.controller.BroadleafAbstractController
addDeepLink, getContextPath, isAjaxRequest, jsonResponse
-
Field Details
-
CHANGE_PASSWORD_USERNAME_REQUEST_ATTR
- See Also:
-
loginView
-
forgotPasswordView
-
forgotUsernameView
-
forgotPasswordSuccessView
-
resetPasswordView
-
resetPasswordErrorView
-
resetPasswordSuccessView
-
resetPasswordFormView
-
forcedPasswordChangeView
-
forcedPasswordChangeSuccessView
-
customerService
protected org.broadleafcommerce.profile.core.service.CustomerService customerService -
resetPasswordValidator
protected org.broadleafcommerce.profile.core.service.validator.ResetPasswordValidator resetPasswordValidator -
loginService
protected org.broadleafcommerce.profile.web.core.service.login.LoginService loginService
-
-
Constructor Details
-
BroadleafLoginController
public BroadleafLoginController()
-
-
Method Details
-
login
public String login(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Redirects to the login view.- Parameters:
request-response-model-- Returns:
- the return view
-
forgotPassword
public String forgotPassword(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Redirects to te forgot password view.- Parameters:
request-response-model-- Returns:
- the return view
-
processForgotPassword
public String processForgotPassword(String username, jakarta.servlet.http.HttpServletRequest request, org.springframework.ui.Model model) Looks up the passed in username and sends an email to the address on file with a reset password token.Returns error codes for invalid username.
- Parameters:
username-request-model-- Returns:
- the return view
-
forcedPasswordChange
public String forcedPasswordChange(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) -
processForcedPasswordChange
-
forgotUsername
public String forgotUsername(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Returns the forgot username view.- Parameters:
request-response-model-- Returns:
- the return view
-
processForgotUsername
public String processForgotUsername(String email, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Looks up an account by email address and if found, sends an email with the associated username.- Parameters:
email-request-response-model-- Returns:
- the return view
-
resetPassword
public String resetPassword(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Displays the reset password view. Expects a valid resetPasswordToken to exist that was generated byprocessForgotPassword(String, HttpServletRequest, Model)or similar. Returns an error view if the token is invalid or expired.- Parameters:
request-response-model-- Returns:
- the return view
-
processResetPassword
public String processResetPassword(ResetPasswordForm resetPasswordForm, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.springframework.validation.BindingResult errors) throws org.broadleafcommerce.common.exception.ServiceException Processes the reset password token and allows the user to change their password. Ensures that the password and confirm password match, that the token is valid, and that the token matches the provided email address.- Parameters:
resetPasswordForm-request-response-model-errors-- Returns:
- the return view
- Throws:
org.broadleafcommerce.common.exception.ServiceException
-
buildRedirectToLoginWithMessage
By default, redirects to the login page with a message.- Parameters:
message-- Returns:
- the return view
-
initResetPasswordForm
Initializes the reset password by ensuring that the passed in token URL parameter initializes the hidden form field.Also, if the reset password request is in the same session as the forgotPassword request, the username will auto-populate
- Parameters:
request-- Returns:
- the return view
-
getLoginView
- Returns:
- the view representing the login page.
-
getForgotUsernameView
- Returns:
- the view displayed for the forgot username form.
-
getForgotPasswordView
- Returns:
- the view displayed for the forgot password form.
-
getResetPasswordView
- Returns:
- the view displayed for the reset password form.
-
getForgotPasswordSuccessView
- Returns:
- the view returned after a successful forgotPassword email has been sent.
-
getForcedPasswordChangeView
- Returns:
- the view displayed for the forced password change form.
-
getForcedPasswordChangeSuccessView
- Returns:
- the view returned after a successful forgotPassword email has been sent.
-
getResetPasswordFormView
- Returns:
- the view name to use for the reset password model..
-
getResetPasswordScheme
-
getResetPasswordPort
-
getResetPasswordUrl
-
getResetPasswordErrorView
View user is directed to if they try to access the resetPasswordForm with an invalid token.- Returns:
- the error view
-
getResetPasswordSuccessView
View that a user is sent to after a successful reset password operations. Should be a redirect (e.g. start with "redirect:" since this will cause the entire SpringSecurity pipeline to be fulfilled.
-