/**
  * Forgot password form processing page.
  *
  * @return Redirect
  */
 public function postForgotPassword()
 {
     // Declare the rules for the validator
     $rules = array('email' => 'required|email');
     // Create a new validator instance from our dynamic rules
     $validator = Validator::make(Input::all(), $rules);
     // If validation fails, we'll exit the operation now.
     if ($validator->fails()) {
         // Ooops.. something went wrong
         return Redirect::to(URL::previous() . '#toforgot')->withInput()->withErrors($validator);
     }
     try {
         // Get the user password recovery code
         //$user = Sentinel::getUserProvider()->findByLogin(Input::get('email'));
         $user = Sentinel::findByCredentials(['email' => Input::get('email')]);
         if (!$user) {
             return Redirect::route('forgot-password')->with('error', Lang::get('auth/message.account_not_found'));
         }
         $activation = Activation::completed($user);
         if (!$activation) {
             return Redirect::route('forgot-password')->with('error', Lang::get('auth/message.account_not_activated'));
         }
         $reminder = Reminder::exists($user) ?: Reminder::create($user);
         // Data to be used on the email view
         $data = array('user' => $user, 'forgotPasswordUrl' => URL::route('forgot-password-confirm', [$user->id, $reminder->code]));
         // Send the activation code through email
         Mail::send('emails.forgot-password', $data, function ($m) use($user) {
             $m->to($user->email, $user->first_name . ' ' . $user->last_name);
             $m->subject('Account Password Recovery');
         });
     } catch (UserNotFoundException $e) {
         // Even though the email was not found, we will pretend
         // we have sent the password reset code through email,
         // this is a security measure against hackers.
     }
     //  Redirect to the forgot password
     return Redirect::to(URL::previous() . '#toforgot')->with('success', Lang::get('auth/message.forgot-password.success'));
 }
Example #2
0
 /**
  * Handle a login request to the application.
  *
  * @param \Illuminate\Http\Request $request        	
  * @return \Illuminate\Http\Response
  */
 public function postLogin(Request $request)
 {
     //dd($request->all());
     //HNjOSGWoVHCNx70UAnbphnAJVIttFvot
     $this->validate($request, ['email' => 'required|email', 'password' => 'required']);
     $credentials = $request->only('email', 'password');
     $user = Sentinel::findByCredentials($credentials);
     if (Sentinel::validateCredentials($user, $credentials)) {
         if (\Activation::completed($user)) {
             $user = Sentinel::authenticate($credentials);
         } else {
             return redirect($this->loginPath())->withInput($request->only('email', 'remember'))->withErrors(["Su usuario no se encuentra activo"]);
         }
     } else {
         return redirect($this->loginPath())->withInput($request->only('email', 'remember'))->withErrors(["Su credencial no es valida"]);
     }
     return redirect($this->loginPath())->withInput($request->only('email', 'remember'))->withErrors(['email' => $this->getFailedLoginMessage()]);
 }
<?php

return array('view' => array('list' => function (array $row) {
}, 'form' => function (array $row) {
    // empty if create form
    $isActive = false;
    if ($row) {
        $user = \Sentinel::findById($row['id']);
        $isActive = \Activation::completed($user);
    }
    return view('jarboe.c.users::patterns.user_activation', compact('isActive'));
}), 'handle' => array('insert' => function ($idRow, $patternValue, $values) {
    if ($patternValue == 'deactivate') {
        return;
    }
    $user = \Sentinel::findById($idRow);
    $activation = \Activation::create($user);
    \Activation::complete($user, $activation->code);
}, 'update' => function ($idRow, $patternValue, $values) {
    $user = \Sentinel::findById($idRow);
    $activation = \Activation::completed($user);
    if (!$activation && $patternValue == 'deactivate') {
        return;
    } elseif ($activation && $patternValue == 'deactivate') {
        \Activation::remove($user);
    } elseif (!$activation && $patternValue == 'activate') {
        $activation = \Activation::create($user);
        \Activation::complete($user, $activation->code);
    }
}, 'delete' => function ($idRow) {
}));