Example #1
0
 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();
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Sentinel::registerAndActivate(array('email' => '*****@*****.**', '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_user = Sentinel::findUserByCredentials($credentials);
     $admin_role = Sentinel::findRoleBySlug('admin');
     $admin_role->users()->attach($admin_user);
 }