Last active
December 23, 2015 17:59
-
-
Save nateabele/6672080 to your computer and use it in GitHub Desktop.
Get the current user as an object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** models/Users.php **/ | |
use lithium\security\Auth; | |
class Users extends \lithium\data\Model { | |
// ... | |
public static function current($request = null) { | |
if ($request === false) { | |
return Auth::clear('default'); | |
} | |
$data = $request ? Auth::check('default', $request) : Auth::check('default'); | |
return $data ? static::create($data, array('exists' => true)) : null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment