Esempio n. 1
0
 public function showWellcome()
 {
     if (Cas::isAuthenticated() == false) {
         Auth::logout();
         return View::make('wellcome');
     }
     if (Auth::check() == true) {
         $sgrUser = new sgrUser(Auth::user());
         return Redirect::to($sgrUser->home());
     }
     return View::make('wellcome');
 }
Esempio n. 2
0
 /**
  * //login
  * @return redirect::to
  */
 public function doLogin()
 {
     if (!Cas::authenticate()) {
         return Redirect::to('report.html')->with('msg', Config::get('msg.errorSSO'))->with('alertLevel', 'danger');
     }
     $attributes = Cas::attr();
     $statusUvus = stripos($attributes['schacuserstatus'], 'uvus:OK');
     //Uvus no valido :)
     if ($statusUvus == false) {
         return Redirect::to(route('report.html'))->with('msg', Config::get('msg.uvusNoValido'))->with('alertLevel', 'danger');
     }
     $user = User::where('username', '=', $attributes['uid'])->first();
     //No existe user en BD => Primer Acceso
     if ($this->existsUser($user) == false) {
         // => registrar acceso
         $this->registraAcceso($attributes);
         // => Salva notificación para admins SGR
         $motivo = 'Nuevo acceso';
         $this->salvaNotificacion($attributes, $motivo);
         // => send mail para admins SGR
         $sgrMail = new sgrMail();
         $sgrMail->notificaRegistroUser($user);
         //notifica a los administradores designados que hay un nuevo usuario a registrar.
         // => Redirect report for user
         return Redirect::to(route('report.html'))->with('msg', Config::get('msg.uvusRegistrado'))->with('alertLevel', 'danger');
     }
     //User existe en BD
     // Cuenta desactivada :)
     if ($user->estado == false) {
         return Redirect::to(route('report.html'))->with('msg', Config::get('msg.uvusNoActivo'))->with('alertLevel', 'danger');
     }
     //Cuenta Caducada :)
     if (strtotime($user->caducidad) < strtotime(date('Y-m-d'))) {
         // => Salva notificación para admins SGR
         $motivo = 'Cuenta caducada';
         $this->salvaNotificacion($attributes, $motivo);
         return Redirect::to(route('report.html'))->with('msg', Config::get('msg.cuentaCaducada'))->with('alertLevel', 'danger');
     }
     //Cuenta OK
     Auth::loginUsingId($user->id);
     $sgrUser = new sgrUser($user);
     return Redirect::to($sgrUser->home());
 }