我目前正在开发一个人们可以提交注册请求的系统。管理员需要接受请求才能使用户能够登录。在我的数据库中,我有一个名为的字段is_request,每次注册时,该字段默认设置为 1(在database) ,意思是。当此字段设置为 1 的用户尝试登录时,需要通知他们其帐户尚未激活。我怎样才能做到这一点?
当用户尝试注册时,会发生以下情况:
protected function create(array $data)
{
$users = User::where('role_id', 1)->get();
$user = User::create([
'firstname' => $data['firstname'],
'lastname' => $data['lastname'],
'email' => $data['email'],
'role_id' => 3,
'activated' => 0,
'user_token' => Str::random(32),
'password' => Hash::make($data['password']),
]);
foreach($users as $admin) {
$admin->notify(new registerRequest($user));
}
Mail::to($user->email)->send(new RegisterRequestSend($user));
return $user;
}
当后端管理员“接受”请求时,该字段is_request将设置为 0,并且用户需要能够登录应用程序。
登录控制器看起来像这样
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
尚方宝剑之说
喵喵时光机