public function ajaxDelete()
 {
     // :)
     //Input
     $id = Input::get('id', '');
     $idnotificacion = Input::get('idnotificacion', '');
     //Output
     $respuesta = array('error' => false, 'errors' => array(), 'msg' => '');
     $rules = array('id' => 'required|exists:users', 'idnotificacion' => 'required|exists:notificaciones,id');
     $messages = array('required' => Config::get('msg.idempty'), 'exists' => Config::get('msg.idnotfound'));
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         $respuesta['error'] = true;
         $respuesta['errors'] = $validator->errors()->toArray();
         return $respuesta;
     } else {
         $user = User::find($id);
         $sgrUser = new sgrUser($user);
         $sgrUser->detach();
         $sgrUser->deleteeventos();
         $sgrUser->delete();
         $respuesta['msg'] = (string) View::make('msg.success')->with(array('msg' => Config::get('msg.delusersuccess')));
         $this->cierraNotificacion($idnotificacion);
         return $respuesta;
     }
 }
Esempio n. 2
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. 3
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());
 }