Authentication Object
Last updated: · Published:
Authentication can be used to secure certain pages on a site. When an authentication type is created, it is possible to create so called authentication objects, which are like "user accounts on a website". An authentication object has two fields by default: email
and password
. However, it is possible to add content fields to the authentication type, just as with other content type kinds.
Authentication Objects
Get all authentication objects for a authentication type.
{{ authentication.dealers }}
Returns all authentication objects for the authentication type 'dealers'.
Authentication types
Every authentication type can be accessed as follows (given that there is an authentication type with the plural name "dealers":
{{ authentication.authentication_types.dealers }}
Then for every authentication type, the following attributes can be retrieved:
login_path
logout_path
edit_path
new_path
request_password_recovery_path
Each of this attributes return a path to a specific authentication template.
Example:
<a href="{{authentication.authentication_types.dealers.login_path}}">Login</a>
<a href="/dealers/login">Login</a>
Current authenticated resources
For each authentication type it is also possible to get the current authenticated resource (account). This can be done by calling 'current_authentication_type_name' on the authentication object. The returned authentication object has the following attributes:
email
Authentication_Type
Next to these attributes, all content fields of the authentication are callable. E.g. when the authentication type of an authentication resource has a content field with the name first_name
, you can call the attribute first_name
on the current authenticated resource.
When the visitor is not authenticated as the specified authentication type, the 'current_authentication_type_name' attribute will return null.
Example:
Given that there is an authentication type with the name dealer
, having a content field first_name
, and the visitor is logged in as an authentication resource with email="john@getplate.com"
and first_name="John"
:
{{ authentication.current_dealer.email }},
{{ authentication.current_dealer.first_name }}
john@getplate.com,
John