FEATURE #2047: use laravel's authorization

This commit is contained in:
Michal Kváček
2017-08-02 13:33:26 +02:00
parent 67fb3c6945
commit a4c020daa0
60 changed files with 1357 additions and 50 deletions
+32 -9
View File
@@ -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));
}
}