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
ModifierConstructorDescriptionprotected
Login()
This constructor is meant to be used when extending theLogin
element with your custom login class.Login
(AuthConfig config, Template template) This constructor is meant to be used when theLogin
element is used directly as a route in your site. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
acceptedCredentials
(Credentials credentials) Hook method that is called when valid credentials have been accepted by theCredentialsManager
that backs this authentication element.protected void
authenticated
(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 Template
Hook method that is called to create the template instance.boolean
hasAttribute
(String key) Checks if a certain attribute is present.protected void
Hook method that is called at the start of the element's processing.void
Process the providedContext
with this element.protected void
refusedCredentials
(Template template, Credentials credentials) Hook method that is called when valid credentials have been rejected by theCredentialsManager
that backs this authentication element.protected void
sessionCreationError
(Template template, Credentials credentials) Hook method that is called when theSessionManager
couldn't create a new authentication session of valid and accepted credentials.protected void
unvalidatedCredentials
(Template template, Credentials credentials) Hook method that is called on login form submission when validation of the credentials produces validation errors.protected void
validatedCredentials
(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 theLogin
element 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 theLogin
element 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 theCredentialsManager
that 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 theCredentialsManager
that 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 theSessionManager
couldn'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:Element
Process the providedContext
with this element.- Specified by:
process
in interfaceElement
- Overrides:
process
in classIdentified
- Parameters:
c
- the provided request/response context- Throws:
Exception
- when an error occurs
-
hasAttribute
Description copied from interface:SessionAttributes
Checks if a certain attribute is present.- Specified by:
hasAttribute
in interfaceSessionAttributes
- Parameters:
key
- The key that identifies the attribute.- Returns:
true
if the attribute was present; orfalse
otherwise.- See Also:
-
getAttribute
Description copied from interface:SessionAttributes
Retrieves the value of a particular attribute.- Specified by:
getAttribute
in interfaceSessionAttributes
- Parameters:
key
- The key that identifies the attribute.- Returns:
- A
String
instance with the value of the requested attribute; ornull
if the attribute couldn't be found. - See Also:
-