API Documentation for: 1.1.1
Show:

Authorization Class

Extends CanteenBase
Namespace: Canteen\Authorization

Responsible for handing the authorization of a user either through login, cookie or session. Located in the namespace Canteen\Authorization.

Methods

checkRemembered

(
  • cookie
)
private

Takes cookie data and varifies user terminate session if no user found

Parameters:

  • cookie String

    The 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]
)
Boolean

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:

  • username String

    The username

  • password String

    The password

  • remember Boolean

    If we're suppose to remember this

  • [isPasswordHashed=false] Boolean optional

    If the password we're supplying is the hashed password

Returns:

Boolean:

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
)
String protected

Inherited from CanteenBase

Convenience method for parsing content

Parameters:

  • content String

    The string to parse

  • substitutions Dictionary

    The dictionary of tags to replace

Returns:

String:

The parsed string

service

(
  • alias
)
Service protected

Inherited from CanteenBase:

Get a service by alias

Parameters:

Returns:

Service:

The service matching the alias

setSession

(
  • user
  • remember
  • [init=true]
)
private

Creates all the session data and assigns user's data to class variables

Parameters:

  • user User

    The User object

  • remember Boolean

    If we should remember this login

  • [init=true] Boolean optional

    If this is the initial login

template

(
  • name
  • [substitutions=[]
)
String protected

Inherited from CanteenBase:

Convenience method for parsing content

Parameters:

  • name String

    The name of the template to parse

  • [substitutions=[] Dictionary optional

    The dictionary of tags to replace

Returns:

String:

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 Int

    The user ID

updatePassword

(
  • password
)
String | Boolean

Update the user password

Parameters:

  • password String

    The plain text password (not hashed)

Returns:

String | Boolean:

If password was set successfully return hash else false

Properties

_domain

String protected

The domain of this user

_ipAddress

String protected

The current ip address

_loggedin

Boolean protected

If there is a user logged in

_sessionId

String protected

The PHP session id

_user

User protected

The user data

cache

ServerCache

Inherited from CanteenBase:

Get the instance of the site cache

cookieName

String

The name of the site cookie

Default: termiteLogin

ERR_DEACTIVATED

String final static

Form error when a user's account has been deactivated

ERR_EMPTY

String final static

Form error when username and password are required

ERR_FROZEN

String final static

Form error when a user's account has been frozen temporarily because the maximum number of failed login attempts

ERR_PASS

String final static

Form error when the password you entered was incorrect

ERR_WRONG

String final static

Form error when the supplied login is incorrect

error

String

Store an error if there was an issue logging in

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

Inherited from CanteenBase:

The parser is responsible for rendering templates

profiler

Profiler

Inherited from CanteenBase:

The instance of the profiler for debugging performance

settings

Dictionary

Inherited from CanteenBase

Get the user data properties

site

Site

Inherited from CanteenBase:

Convenience getter for the site

user

Authorization

Inherited from CanteenBase:

Get the Authorization class to handle things like login, password change