本文整理汇总了PHP中Sentinel::findUserByCredentials方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentinel::findUserByCredentials方法的具体用法?PHP Sentinel::findUserByCredentials怎么用?PHP Sentinel::findUserByCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentinel
的用法示例。
在下文中一共展示了Sentinel::findUserByCredentials方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendResetEmail
protected function sendResetEmail(Request $request)
{
// we get the user
if (!($user = \Sentinel::findUserByCredentials($request->only('email')))) {
// we flash the request
$request->flash();
// we notify the current user
Modal::alert([trans('auth.message.find.failure', ['email' => $request->get('email')])], 'error');
return redirect()->back();
}
try {
// we create a sentinel reminder for the user
$reminder = Reminder::create($user);
// we send the email with the reminder token
Mail::send('emails.password-reset', ['user' => $user, 'token' => $reminder->code], function ($email) use($user) {
$email->from(config('mail.from.address'), config('mail.from.name'))->to($user->email, $user->first_name . ' ' . $user->last_name)->subject(config('mail.subject.prefix') . ' ' . trans('emails.password_reset.subject'));
});
// notify the user & redirect
Modal::alert([trans('auth.message.password_reset.email.success', ['email' => $user->email])], 'success');
return redirect(route('login.index'));
} catch (Exception $e) {
// we flash the request
$request->flash();
// we log the error
CustomLog::error($e);
// notify the user & redirect
Modal::alert([trans('auth.message.password_reset.email.failure'), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Sentinel::registerAndActivate(array('email' => 'admin@app.com', 'password' => '123456', 'first_name' => 'Admin', 'last_name' => 'App'));
$admin_role = Sentinel::getRoleRepository()->createModel()->create(array('name' => 'Admin', 'slug' => 'admin', 'permissions' => array('admin' => true, 'users' => true)));
$user_role = Sentinel::getRoleRepository()->createModel()->create(array('name' => 'Users', 'slug' => 'user', 'permissions' => array('admin' => false, 'users' => true)));
// Assign user permissions
$credentials = ['login' => 'admin@app.com'];
$admin_user = Sentinel::findUserByCredentials($credentials);
$admin_role = Sentinel::findRoleBySlug('admin');
$admin_role->users()->attach($admin_user);
}