當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sentinel::findUserByCredentials方法代碼示例

本文整理匯總了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();
     }
 }
開發者ID:Okipa,項目名稱:una.app,代碼行數:30,代碼來源:PasswordController.php

示例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);
 }
開發者ID:benhanks040888,項目名稱:Laravel-5-starter-kit,代碼行數:16,代碼來源:SentinelSeeder.php


注:本文中的Sentinel::findUserByCredentials方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。