PHP 클래스 A1_Core

bcrypt is highly recommended by many to safely store passwords. For more information, see http://codahale.com/how-to-safely-store-a-password/ Based on Kohana's AUTH, Fred Wu's AUTHLITE and Woody Gilk's Bonafide
파일 보기 프로젝트 열기: wouterrr/a1

보호된 프로퍼티들

프로퍼티 타입 설명
$_config
$_name
$_sess
$_user

공개 메소드들

메소드 설명
check ( $password, $hash ) : boolean Checks if password matches hash
check_password ( $user, $password ) : boolean Validates a password against a user. This can be used to confirm user in actions where you ask for password while user is logged in to be extra safe (eg when deleting account)
complete_login ( $user, $remember = FALSE ) : TRUE Updates session, set remember cookie (if required)
failed_login ( $user ) : FALSE Registers a failed login attempt
get_user ( ) : object Returns the user - if any
hash ( $input, $salt = NULL, $cost = NULL ) : string Generates bcrypt hash for input
instance ( $_name = 'a1' ) : object Return a static instance of A1.
logged_in ( ) : boolean Returns TRUE is a user is currently logged in
login ( $username, $password, $remember = FALSE ) : mixed Attempt to log in a user.
logout ( $destroy = FALSE ) : boolean Log out a user by removing the related session variables.
session ( $id = NULL ) : Session (Initializes &) Returns the session we're working with
set_user ( $user ) : object Sets the user that is logged in
store_user_in_session ( $user ) : void Stores user model in session

보호된 메소드들

메소드 설명
__construct ( $_name = 'a1', $_config ) : void Loads Session and configuration options.
_get_failed_attempts ( $user ) : void Returns the number of failed login attempts
_increment_failed_attempts ( $user ) : void Increment the number of failed login attempts since last successfull login
_increment_logins ( $user ) : void Increment the number of logins of the user by 1
_load_user ( $username ) : object Loads the user object from database using username
_reset_failed_attempts ( $user ) : void Reset the number of failed login attempts
_save_user ( $user ) : void Saves the user object
_set_last_attempt ( $user ) : void Sets the last attempt field of the user object to current time
_set_last_login ( $user ) : void Sets the last login field of the user object to current time
find_user ( ) : object Finds the user in the session (if any)

메소드 상세

__construct() 보호된 메소드

Loads Session and configuration options.
protected __construct ( $_name = 'a1', $_config ) : void
리턴 void

_get_failed_attempts() 보호된 메소드

Returns the number of failed login attempts
protected _get_failed_attempts ( $user ) : void
리턴 void

_increment_failed_attempts() 보호된 메소드

Increment the number of failed login attempts since last successfull login
protected _increment_failed_attempts ( $user ) : void
리턴 void

_increment_logins() 보호된 메소드

Increment the number of logins of the user by 1
protected _increment_logins ( $user ) : void
리턴 void

_load_user() 추상적인 보호된 메소드

Loads the user object from database using username
abstract protected _load_user ( $username ) : object
리턴 object User Object

_reset_failed_attempts() 보호된 메소드

Reset the number of failed login attempts
protected _reset_failed_attempts ( $user ) : void
리턴 void

_save_user() 보호된 메소드

Saves the user object
protected _save_user ( $user ) : void
리턴 void

_set_last_attempt() 보호된 메소드

Sets the last attempt field of the user object to current time
protected _set_last_attempt ( $user ) : void
리턴 void

_set_last_login() 보호된 메소드

Sets the last login field of the user object to current time
protected _set_last_login ( $user ) : void
리턴 void

check() 공개 메소드

Checks if password matches hash
public check ( $password, $hash ) : boolean
리턴 boolean password matches hashed password

check_password() 공개 메소드

if ( $a1->check_password($user, $this->request->post('password'))) { delete account or some other special action }
public check_password ( $user, $password ) : boolean
리턴 boolean Success

complete_login() 공개 메소드

Updates session, set remember cookie (if required)
public complete_login ( $user, $remember = FALSE ) : TRUE
리턴 TRUE

failed_login() 공개 메소드

Registers a failed login attempt
public failed_login ( $user ) : FALSE
리턴 FALSE

find_user() 보호된 메소드

Finds the user in the session (if any)
protected find_user ( ) : object
리턴 object / FALSE

get_user() 공개 메소드

Returns the user - if any
public get_user ( ) : object
리턴 object / FALSE

hash() 공개 메소드

Generates bcrypt hash for input
public hash ( $input, $salt = NULL, $cost = NULL ) : string
리턴 string hashed input value

instance() 공개 정적인 메소드

Return a static instance of A1.
public static instance ( $_name = 'a1' ) : object
리턴 object

logged_in() 공개 메소드

Returns TRUE is a user is currently logged in
public logged_in ( ) : boolean
리턴 boolean

login() 공개 메소드

Attempt to log in a user.
public login ( $username, $password, $remember = FALSE ) : mixed
리턴 mixed user if succesfull, FALSE otherwise

logout() 공개 메소드

Log out a user by removing the related session variables.
public logout ( $destroy = FALSE ) : boolean
리턴 boolean

session() 공개 메소드

(Initializes &) Returns the session we're working with
public session ( $id = NULL ) : Session
리턴 Session

set_user() 공개 메소드

Sets the user that is logged in
public set_user ( $user ) : object
리턴 object / FALSE

store_user_in_session() 공개 메소드

Stores user model in session
public store_user_in_session ( $user ) : void
리턴 void

프로퍼티 상세

$_config 보호되어 있는 프로퍼티

protected $_config

$_name 보호되어 있는 프로퍼티

protected $_name

$_sess 보호되어 있는 프로퍼티

protected $_sess

$_user 보호되어 있는 프로퍼티

protected $_user