Authorization Class
Responsible for handing the authorization of a user either through login, cookie or session. Located in the namespace Canteen\Authorization.
Item Index
Methods
Properties
- _domain
- _ipAddress
- _loggedin
- _sessionId
- _user
- cache
- cookieName
- ERR_DEACTIVATED static
- ERR_EMPTY static
- ERR_FROZEN static
- ERR_PASS static
- ERR_WRONG static
- error
- frozenMinutes
- loginAttempts
- loginExpires
- parser
- profiler
- settings
- site
- user
Methods
checkRemembered
-
cookie
Takes cookie data and varifies user terminate session if no user found
Parameters:
-
cookie
StringThe cookie to get the login from
checkSession
()
private
Validates user based on existing session information if no user exists, kill session and logout.
clear
()
private
Defaults for all the user's relevant data
login
-
username
-
password
-
remember
-
[isPasswordHashed=false]
Queries database for entry matching username and password. Password needs to be sent in as hash value. Remember is a boolean to save cookie or not
Parameters:
Returns:
If the user has been logged in
logout
()
The logout function terminates session and eliminates all session data cookie is also cleared
parse
-
content
-
substitutions
Convenience method for parsing content
Parameters:
-
content
StringThe string to parse
-
substitutions
DictionaryThe dictionary of tags to replace
Returns:
The parsed string
service
-
alias
Get a service by alias
Parameters:
-
alias
StringThe alias
Returns:
The service matching the alias
setSession
-
user
-
remember
-
[init=true]
Creates all the session data and assigns user's data to class variables
template
-
name
-
[substitutions=[]
Convenience method for parsing content
Parameters:
-
name
StringThe name of the template to parse
-
[substitutions=[]
Dictionary optionalThe dictionary of tags to replace
Returns:
The parsed string
updateCookie
-
userId
Create the cookie to be remembered later, if the user updates their password make sure you update the cookie
Parameters:
-
userId
IntThe user ID
Properties
ERR_FROZEN
String
final
static
Form error when a user's account has been frozen temporarily because the maximum number of failed login attempts
frozenMinutes
Int
The number of minutes a user is locked from their account
Default: 15
loginAttempts
Int
The number of attempts that a user can make before being locked out
Default: 5
loginExpires
Int
How long, in seconds, to save the login cookie
Default: 2592000
parser
Parser
The parser is responsible for rendering templates
profiler
Profiler
The instance of the profiler for debugging performance
settings
Dictionary
Get the user data properties