User   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 41
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App;
4
5
use Illuminate\Auth\Authenticatable;
6
use Laravel\Lumen\Auth\Authorizable;
7
use Illuminate\Database\Eloquent\Model;
8
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
9
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
10
11
use Illuminate\Support\Facades\Hash;
12
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