inc\classes\Auth.phpView Source

Show: PublicProtectedPrivateinherited
Table of Contents
File, which contains class
Author
Sergey Dilong  
License
GPL-2.0  
Package
Temply-Account\Services  

\Auth

Package: Temply-Account\Services
Authorization and current account control

Used to all auth purposes and getting current user info

Author
Sergey Dilong  
License
GPL-2.0  

Properties

>VPropertyprivatearray<mixed,mixed> $data = array()
static

Current user info

Default valuearray()Details
Type
array<mixed,mixed>
See
Get current User  
>VPropertyprivateboolean $init = false
static

Checks if Auth() was already inited

Default valuefalseDetails
Type
boolean
See
Look up where it is used  
>VPropertyprivatestring $token = false

64 symbols unique access key

Default valuefalseDetails
Type
string
See
Get token outside the class  

Methods

methodpublicInit() : void
static

Prepare Auth system

Generates template for login sysyem (Later used for current token data).

methodpublicUser(boolean $r = false) : \User | array
static

Current user

Recieve current User object

If $r === true: User->get() will be returned, else - class User

Parameters
NameTypeDescription
$rboolean

Return switcher

Returns
TypeDescription
\User | array
Details
See
 
methodpublic__construct(string $act = '') : void

Launch Auth system

Parameters
NameTypeDescription
$actstring

Navigator string

  • auth - New login. Uses user-passed credentials (login and password fields)
  • checkToken - Just check token without other instances
  • - Requires login
Throws
ExceptionDescription
\apiException* [300] DB Error * [301] Invalid credentials for login * [302] There's no such token in DB
Details
Example
Auth could be called by statements  
See
Login function  
See
Login check function  
See
Get token outside the class  
See
Get current User  
methodprivatecheck(string $t) : boolean

Check token

Checks if given token is correct

Parameters
NameTypeDescription
$tstring

64-symbols long token

Returns
TypeDescription
booleanIf `true` - token is correct
Throws
ExceptionDescription
\apiException* [302] Incorrect token
Details
Api
 
See
Call this method outside the class  
methodpublicgetTokenData() : array
static

Get token, etc.

Get such data as token and verify status

Returns
TypeDescription
arrayToken data * *token* - [string] 64-symbols length * *verify* - [boolean] if `true` - token is checked
Details
Api
 
Uses
as data source  
methodprivatenewToken(string $l, string $p) : boolean

New token

Auth with login and password

Parameters
NameTypeDescription
$lstring

Login

$pstring

Password

Returns
TypeDescription
booleanIf `true` - login successful
Throws
ExceptionDescription
\apiException* [300] DB Error * [301] Invalid credentials for login
Details
Api
 
See
Use this method outside the class  
methodprivaterecord(array $data) : void
static

Write current user data

Saves current user to class field

Parameters
NameTypeDescription
$dataarray

User's data

Details
See
Where this function used  
Uses
to store data  
Documentation was generated by phpDocumentor v2.9.0.