PHP Class LoginModel, huge

Author: anza
Inheritance: extends Model
Mostrar archivo Open project: panique/huge Class Usage Examples

Public Methods

Method Description
deleteCookie ( string $user_id = null ) Deletes the cookie It's necessary to split deleteCookie() and logout() as cookies are deleted without logging out too! Sets the remember-me-cookie to ten years ago (3600sec * 24 hours * 365 days * 10).
incrementFailedLoginCounterOfUser ( $user_name ) Increments the failed-login counter of a user
isUserLoggedIn ( ) : boolean Returns the current state of the user's login
login ( $user_name, $user_password, $set_remember_me_cookie = null ) : boolean Login process (for DEFAULT user accounts).
loginWithCookie ( $cookie ) : boolean performs the login via cookie (for DEFAULT user account, FACEBOOK-accounts are handled differently) TODO add throttling here ?
logout ( ) Log out process: delete cookie, delete session
resetFailedLoginCounterOfUser ( $user_name ) Resets the failed-login counter of a user back to 0
saveTimestampOfLoginOfUser ( $user_name ) Write timestamp of this login into database (we only write a "real" login via login form into the database, not the session-login on every page request
setRememberMeInDatabaseAndCookie ( $user_id ) Write remember-me token into database and into cookie Maybe splitting this into database and cookie part ?
setSuccessfulLoginIntoSession ( $user_id, $user_name, $user_email, $user_account_type ) The real login process: The user's data is written into the session.

Private Methods

Method Description
incrementUserNotFoundCounter ( ) Increment the failed-login-count by 1.
resetUserNotFoundCounter ( ) Reset the failed-login-count to 0.
validateAndGetUser ( $user_name, $user_password ) : boolean | mixed Validates the inputs of the users, checks if password is correct etc.

Method Details

deleteCookie() public static method

that's obviously the best practice to kill a cookie @see http://stackoverflow.com/a/686166/1114320
public static deleteCookie ( string $user_id = null )
$user_id string

incrementFailedLoginCounterOfUser() public static method

Increments the failed-login counter of a user
public static incrementFailedLoginCounterOfUser ( $user_name )
$user_name

isUserLoggedIn() public static method

Returns the current state of the user's login
public static isUserLoggedIn ( ) : boolean
return boolean user's login status

login() public static method

Login process (for DEFAULT user accounts).
public static login ( $user_name, $user_password, $set_remember_me_cookie = null ) : boolean
$user_name string The user's name
$user_password string The user's password
$set_remember_me_cookie mixed Marker for usage of remember-me cookie feature
return boolean success state

loginWithCookie() public static method

performs the login via cookie (for DEFAULT user account, FACEBOOK-accounts are handled differently) TODO add throttling here ?
public static loginWithCookie ( $cookie ) : boolean
$cookie string The cookie "remember_me"
return boolean success state

logout() public static method

Log out process: delete cookie, delete session
public static logout ( )

resetFailedLoginCounterOfUser() public static method

Resets the failed-login counter of a user back to 0
public static resetFailedLoginCounterOfUser ( $user_name )
$user_name

saveTimestampOfLoginOfUser() public static method

Write timestamp of this login into database (we only write a "real" login via login form into the database, not the session-login on every page request
public static saveTimestampOfLoginOfUser ( $user_name )
$user_name

setRememberMeInDatabaseAndCookie() public static method

Write remember-me token into database and into cookie Maybe splitting this into database and cookie part ?
public static setRememberMeInDatabaseAndCookie ( $user_id )
$user_id

setSuccessfulLoginIntoSession() public static method

Cheesy name, maybe rename. Also maybe refactoring this, using an array.
public static setSuccessfulLoginIntoSession ( $user_id, $user_name, $user_email, $user_account_type )
$user_id
$user_name
$user_email
$user_account_type