Exemplo n.º 1
0
 /**
  * Handle posting of the form for logging the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function processLogin(Request $request)
 {
     try {
         $email = $request->get('email');
         $password = $request->get('password');
         $remember = empty($request->get('remember')) ? false : true;
         $rules = ['email' => 'required|email', 'password' => 'required'];
         $input = Input::all();
         $validator = Validator::make($input, $rules);
         if ($validator->fails()) {
             return Redirect::back()->withInput()->withErrors($validator);
         }
         $user = Sentinel::authenticate(array('email' => $email, 'password' => $password), $remember);
         if ($user === false) {
             //user not authenticated
             return view('auth.login')->withErrors("Mauvaise combinaison de nom d'utilisateur/email et mot de passe");
         } else {
             //user is authenticated
             return redirect()->intended('/');
         }
     } catch (NotActivatedException $e) {
         $errors = 'Account is not activated!';
         return Redirect::to('reactivate')->with('user', $e->getUser())->withErrors('Account is not activated!');
     } catch (ThrottlingException $e) {
         $delay = $e->getDelay();
         $errors = "Your account is blocked for {$delay} second(s).";
     }
     return Redirect::back()->withInput()->withErrors($errors);
 }
Exemplo n.º 2
0
 /**
  * Handle posting of the form for logging the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function processLogin(Request $request)
 {
     try {
         $input = $request->all();
         $rules = ['email' => 'required|email', 'password' => 'required'];
         $validator = \Validator::make($input, $rules);
         if ($validator->fails()) {
             return \Redirect::back()->withInput()->withErrors($validator);
         }
         if (Sentinel::authenticate($input, false)) {
             return \Redirect::intended('/');
         }
         $errors = 'El correo electrónico y/o contraseña no coinciden.';
     } catch (NotActivatedException $e) {
         $errors = 'Account is not activated!';
         return Redirect::to('login')->with('user', $e->getUser());
     } catch (ThrottlingException $e) {
         $delay = $e->getDelay();
         $errors = "Your account is blocked for {$delay} second(s).";
     }
     return \Redirect::back()->withInput()->withErrors($errors);
 }
Exemplo n.º 3
0
<?php

require_once "../includes.php";
use Cartalyst\Sentinel\Native\Facades\Sentinel;
use Illuminate\Database\Capsule\Manager as Capsule;
$_SESSION["flash"] = "Sign in to Mivtzoim.net";
if (!empty($_POST)) {
    $credentials = ['email' => $_POST["email"], 'password' => $_POST["password"]];
    if ($user = Sentinel::authenticate($credentials, true)) {
        Sentinel::login($user, true);
        $_SESSION["flash"] = "Welcome on Board!";
        set_session();
        header('Location:' . $_SESSION["login_redirect"]);
        die;
    } else {
        $_SESSION["flash"] = "The email and password entered don't match. Please try again.";
    }
}
?>

<h1><?php 
echo $_SESSION["flash"];
?>
</h1>

<form action="login.php" method="post">
  <div> 
    <label for="email"> Email </label>
    <input type="email" name="email" id="email" required>
  </div>
  <div>
Exemplo n.º 4
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()]);
 }