1 | <?php |
||
13 | class User extends Model implements AuthenticatableContract, AuthorizableContract |
||
14 | { |
||
15 | use Authenticatable, Authorizable; |
||
16 | |||
17 | /** |
||
18 | * The attributes that are mass assignable. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $fillable = [ |
||
23 | 'id', 'name', 'email', |
||
24 | ]; |
||
25 | |||
26 | /** |
||
27 | * The attributes excluded from the model's JSON form. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $hidden = [ |
||
32 | 'created_at', 'updated_at', 'password', 'is_admin', |
||
33 | ]; |
||
34 | |||
35 | /** |
||
36 | * Verify user's credentials. |
||
37 | * |
||
38 | * @param string $email |
||
39 | * @param string $password |
||
40 | * @return int|boolean |
||
41 | * @see https://github.com/lucadegasperi/oauth2-server-laravel/blob/master/docs/authorization-server/password.md |
||
42 | */ |
||
43 | public function verify($email, $password){ |
||
44 | |||
45 | $user = User::where('email', $email)->first(); |
||
46 | |||
47 | if($user && Hash::check($password, $user->password)){ |
||
48 | return $user->id; |
||
49 | } |
||
50 | |||
51 | return false; |
||
52 | } |
||
53 | } |
||
54 |