FEATURE #2047: use laravel's authorization
This commit is contained in:
+32
-9
@@ -2,18 +2,27 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Notifications\ResetPasswordNotification;
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticableInterface;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\Access\Authorizable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*/
|
||||
class User extends Model implements AuthenticableInterface
|
||||
class User extends Model implements AuthenticableInterface, CanResetPassword
|
||||
{
|
||||
use SoftDeletes, Authenticatable, Authorizable;
|
||||
use SoftDeletes, Authenticatable, Authorizable, Notifiable;
|
||||
const STATE_DELETED = 'deleted';
|
||||
const STATE_BLOCKED = 'blocked';
|
||||
const STATE_ACTIVE = 'active';
|
||||
const ROLE_VISITOR = 'visitor';
|
||||
const ROLE_EDITOR = 'editor';
|
||||
const ROLE_ADMIN = 'admin';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'email',
|
||||
@@ -24,17 +33,31 @@ class User extends Model implements AuthenticableInterface
|
||||
];
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
const STATE_DELETED = 'deleted';
|
||||
const STATE_BLOCKED = 'blocked';
|
||||
const STATE_ACTIVE = 'active';
|
||||
const ROLE_VISITOR = 'visitor';
|
||||
const ROLE_EDITOR = 'editor';
|
||||
const ROLE_ADMIN = 'admin';
|
||||
|
||||
/**
|
||||
* Get the e-mail address where password reset links are sent.
|
||||
* @return string
|
||||
*/
|
||||
public function getEmailForPasswordReset()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the password reset notification.
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
$this->notify(new ResetPasswordNotification($token));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user