UserLogin
extends SiteAction
in package
Uses
Login
A class to handle the /login, /logout, /register, /forgot and /resend actions
Table of Contents
- $maxage : int
- checketag() : bool
- Check an etag to see if we need to send the page again or not.
- checkLogin() : bool
- Process the login form
- checkmodtime() : bool
- Check a timestamp to see if we need to send the page again or not.
- checkRest() : array<, string>
- Validate the number of fields in the rest of the URL
- confirm() : string
- Handle things to do with email address confirmation
- exists() : bool
- Returns true of the request would generate a page.
- forgot() : string
- Handle things to do with password reset
- handle() : string
- Handle /login /logout /register /forgot /confirm
- ifmodcheck() : void
- Look to see if there are any IF... headers, and deal with them. Exit if a 304 or 412 is generated.
- lastmodified() : int
- Get a last modified time for the page
- login() : string
- Handle a login
- logout() : void
- Handle a logout
- makeetag() : string
- Make an etag for an item
- makemaxage() : int
- Make a max age value for an item
- makemod() : string
- Format a time suitable for Last-Modified header
- register() : string
- handle a registration
- set304Cache() : void
- Set any cache headers that are wanted on a 304 response
- setCache() : void
- Set any cache headers that are wanted for a normal page delivery
- setCSP() : void
- Set up any CSP headers for a page
- eorl() : OODBBean|null
- Find a user based on either a login or an email address
- etagmatched() : void
- We have a matched etag - check request method and send the appropriate header.
- makecode() : string
- Make a confirmation code and store it in the database
- sendconfirm() : void
- Mail a confirmation code
- sendreset() : void
- Mail a password reset code
Properties
$maxage
protected
static int
$maxage
= 3600
- the default maxage for a page. This is a static because you can't have consts in a trait....
Methods
checketag()
Check an etag to see if we need to send the page again or not.
public
checketag(Context $context, string $tag) : bool
Parameters
- $context : Context
-
The context object for the site
- $tag : string
-
The etag value to check
Return values
bool —checkLogin()
Process the login form
public
checkLogin(Context $context) : bool
Different kinds of logins might be required. This is the default that uses the local database table.
Parameters
- $context : Context
Tags
Return values
bool —checkmodtime()
Check a timestamp to see if we need to send the page again or not.
public
checkmodtime(Context $context, string $time) : bool
This always returns FALSE, indicating that we need to send the page again. The assumption is that pages that implement etags will override this function appropriately to do actual value checking.
Parameters
- $context : Context
-
The context object for the site
- $time : string
-
The time value to check
Tags
Return values
bool —checkRest()
Validate the number of fields in the rest of the URL
public
checkRest(array<, string> $rest, int $start, int $num[, array<, string> $format = [] ]) : array<, string>
Parameters
- $rest : array<, string>
- $start : int
-
The element to start at
- $num : int
-
The number of params required
- $format : array<, string> = []
-
Currently not used
Tags
Return values
array<, string> —confirm()
Handle things to do with email address confirmation
public
confirm(Context $context) : string
Parameters
- $context : Context
-
The context object for the site
Return values
string —A template name
exists()
Returns true of the request would generate a page.
public
exists(Context $context) : bool
This needs to be overridden if it is to be used. Currently returns TRUE, thus assuming that pages always exist....
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
bool —forgot()
Handle things to do with password reset
public
forgot(Context $context) : string
Parameters
- $context : Context
-
The context object for the site
Return values
string —A template name
handle()
Handle /login /logout /register /forgot /confirm
public
handle(Context $context) : string
Parameters
- $context : Context
-
The context object for the site
Return values
string —A template name
ifmodcheck()
Look to see if there are any IF... headers, and deal with them. Exit if a 304 or 412 is generated.
public
ifmodcheck(Context $context) : void
Parameters
- $context : Context
Tags
Return values
void —lastmodified()
Get a last modified time for the page
public
lastmodified(Context $context) : int
By default this returns the current time. For pages that need to use this in anger, then this function may need to be overridden.
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
int —login()
Handle a login
public
login(Context $context) : string
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
string —A template name
logout()
Handle a logout
public
logout(Context $context) : void
Clear all the session material if any and then divert to the /login page
Code taken directly from the PHP session_destroy manual page
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
void —makeetag()
Make an etag for an item
public
makeetag(Context $context) : string
This needs to be overridden by pages that can generate etags
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
string —makemaxage()
Make a max age value for an item
public
makemaxage(Context $context) : int
This needs to be overridden by pages that want to use this
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
int —makemod()
Format a time suitable for Last-Modified header
public
makemod(int $time) : string
Parameters
- $time : int
-
The last modified time
Return values
string —register()
handle a registration
public
register(Context $context) : string
Parameters
- $context : Context
-
The context object for the site
Return values
string —A template name
set304Cache()
Set any cache headers that are wanted on a 304 response
public
set304Cache(Context $context) : void
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
void —setCache()
Set any cache headers that are wanted for a normal page delivery
public
setCache(Context $context) : void
Parameters
- $context : Context
-
The context object
Tags
Return values
void —setCSP()
Set up any CSP headers for a page
public
setCSP() : void
There will be a basic set of default CSP permissions for the site to function, but individual pages may wish to extend or restrict these.
Tags
Return values
void —eorl()
Find a user based on either a login or an email address
private
static eorl(string $lg) : OODBBean|null
Parameters
- $lg : string
-
A username or email address
Return values
OODBBean|null —The user or NULL
etagmatched()
We have a matched etag - check request method and send the appropriate header.
private
etagmatched(Context $context) : void
Does not return
Parameters
- $context : Context
Tags
Return values
void —makecode()
Make a confirmation code and store it in the database
private
makecode(Context $context, OODBBean $bn, string $kind) : string
Parameters
- $context : Context
-
The context bean
- $bn : OODBBean
-
A User bean
- $kind : string
Return values
string —sendconfirm()
Mail a confirmation code
private
sendconfirm(Context $context, OODBBean $bn) : void
Parameters
- $context : Context
-
The context object
- $bn : OODBBean
-
A User bean
Return values
void —sendreset()
Mail a password reset code
private
sendreset(Context $context, OODBBean $bn) : void
Parameters
- $context : Context
-
The context object
- $bn : OODBBean
-
A User bean