Class Login
- All Implemented Interfaces:
SessionAttributes,Element
To customize the behavior of the authentication, it's the easiest to override one of the hook methods.
- Since:
- 1.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLogin()This constructor is meant to be used when extending theLoginelement with your custom login class.Login(AuthConfig config, Template template) This constructor is meant to be used when theLoginelement is used directly as a route in your site. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidacceptedCredentials(Credentials credentials) Hook method that is called when valid credentials have been accepted by theCredentialsManagerthat backs this authentication element.protected voidauthenticated(long userId) Hook method that is called after a new authentication session has been successfully created.getAttribute(String key) Retrieves the value of a particular attribute.protected TemplateHook method that is called to create the template instance.booleanhasAttribute(String key) Checks if a certain attribute is present.protected voidHook method that is called at the start of the element's processing.voidProcess the providedContextwith this element.protected voidrefusedCredentials(Template template, Credentials credentials) Hook method that is called when valid credentials have been rejected by theCredentialsManagerthat backs this authentication element.protected voidsessionCreationError(Template template, Credentials credentials) Hook method that is called when theSessionManagercouldn't create a new authentication session of valid and accepted credentials.protected voidunvalidatedCredentials(Template template, Credentials credentials) Hook method that is called on login form submission when validation of the credentials produces validation errors.protected voidvalidatedCredentials(Credentials credentials) Hook method that is called on login form submission when the credentials are validated without errorsMethods inherited from class rife.authentication.elements.Identified
getAuthConfig, getIdentifiedElementInRequest, getIdentity, initializeIdentified, setIdentityAttribute
-
Constructor Details
-
Login
protected Login()This constructor is meant to be used when extending theLoginelement with your custom login class.Don't forget to also override the `getAuthConfig()` and `getTemplate()` methods.
- Since:
- 1.0
-
Login
This constructor is meant to be used when theLoginelement is used directly as a route in your site.When extending this element, use the default constructor instead and override the `getAuthConfig()` and `getTemplate()` methods.
- Parameters:
config- the auth config to usetemplate- the template instance blueprint to use- Since:
- 1.0
-
-
Method Details
-
initializeLogin
Hook method that is called at the start of the element's processing.- Parameters:
c- the element processing context- Since:
- 1.0
-
getTemplate
Hook method that is called to create the template instance.- Returns:
- the template to use for login
- Since:
- 1.0
-
unvalidatedCredentials
Hook method that is called on login form submission when validation of the credentials produces validation errors.- Parameters:
template- this authentication element's templatecredentials- the credentials object that was invalid- Since:
- 1.0
-
validatedCredentials
Hook method that is called on login form submission when the credentials are validated without errors- Parameters:
credentials- the credentials object that was valid- Since:
- 1.0
-
acceptedCredentials
Hook method that is called when valid credentials have been accepted by theCredentialsManagerthat backs this authentication element.- Parameters:
credentials- the credentials object that was accepted- Since:
- 1.0
-
authenticated
protected void authenticated(long userId) Hook method that is called after a new authentication session has been successfully created.- Parameters:
userId- the user ID of the user that was successfully authenticated- Since:
- 1.0
-
refusedCredentials
Hook method that is called when valid credentials have been rejected by theCredentialsManagerthat backs this authentication element.This can for example happen when the password is not correct.
Note that there is already a default implementation of this hook method that simply adds a validation error to the credentials object. If you want to preserve this when you implement your own hook method, you need to call the super class's method in your implementation.
- Parameters:
template- this authentication element's templatecredentials- the credentials object that was rejected- Since:
- 1.0
-
sessionCreationError
Hook method that is called when theSessionManagercouldn't create a new authentication session of valid and accepted credentials.Note that there is already a default implementation of this hook method that simply adds a validation error to the credentials object. If you want to preserve this when you implement your own hook method, you need to call the super class's method in your implementation.
- Parameters:
template- this authentication element's templatecredentials- the credentials object that was used when creating the authentication session- Since:
- 1.0
-
process
Description copied from interface:ElementProcess the providedContextwith this element.- Specified by:
processin interfaceElement- Overrides:
processin classIdentified- Parameters:
c- the provided request/response context- Throws:
Exception- when an error occurs
-
hasAttribute
Description copied from interface:SessionAttributesChecks if a certain attribute is present.- Specified by:
hasAttributein interfaceSessionAttributes- Parameters:
key- The key that identifies the attribute.- Returns:
trueif the attribute was present; orfalseotherwise.- See Also:
-
getAttribute
Description copied from interface:SessionAttributesRetrieves the value of a particular attribute.- Specified by:
getAttributein interfaceSessionAttributes- Parameters:
key- The key that identifies the attribute.- Returns:
- A
Stringinstance with the value of the requested attribute; ornullif the attribute couldn't be found. - See Also:
-