当前位置: 首页>>代码示例>>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;未经允许,请勿转载。