public function getList()
 {
     $albums = Album::with('Photos')->with('User')->get();
     echo var_export(\Sentry::findUserById(\Sentry::getUser()->id));
     exit;
     return View::make('index')->with('albums', $albums);
 }
Example #2
0
 public function change()
 {
     if (Request::isMethod('post')) {
         try {
             $rules = Validator::make(Input::all(), ['password' => 'required|confirmed', 'password_confirmation' => 'required']);
             if ($rules->fails()) {
                 throw new Exception('Todos los campos son obligatorios');
             }
             $data = explode('@', Input::get('data'));
             $id = base64_decode($data[1]);
             $user = Sentry::findUserById($id);
             $admin = Sentry::findGroupByName('Administrador');
             if (!$user->checkResetPasswordCode($data[0])) {
                 throw new Exception('El cĆ³digo de chequeo no es correcto.');
             }
             if (!$user->attemptResetPassword($data[0], Input::get('password_confirmation'))) {
                 throw new Exception('Se presento un error al guardar la nueva contraseƱa.');
             }
             if (!$user->inGroup($admin) || !$user->isActivated()) {
                 throw new Exception('Este usuario no tiene permisos para ingresar o esta inactivo.');
             }
             Sentry::login($user);
             return Redirect::route('admin.dashboard');
         } catch (Exception $e) {
             $uri = URL::route('admin.forgot-reset', [Input::get('data')]);
             return Redirect::to($uri)->with('message', $e->getMessage());
         }
     }
 }
 public function loginByToken($token = '')
 {
     if ($token) {
         $token = base64_decode($token);
         if (User::where('emf_token', '=', $token)->count()) {
             $user = User::where('emf_token', '=', $token)->first();
             if (is_null($user->last_login)) {
                 $start_page = 'walkthrough';
                 $maildata = new stdClass();
                 $maildata->user = $user->toArray();
                 Mail::later(8, 'emails.emf.welcome', (array) $maildata, function ($message) use($user) {
                     $message->to($user->email, $user->first_name && $user->last_name ? $user->first_name . ' ' . $user->last_name : null)->subject('Welcome!');
                 });
             } else {
                 $start_page = 'dashboard';
             }
             $sentry_user = Sentry::findUserById($user->id);
             Sentry::login($sentry_user, false);
             $user->password = md5(uniqid(mt_rand(), true));
             $user->emf_token = null;
             $user->updated_at = time();
             if ($user->save()) {
                 Log::info('loginByToken() User information was updated.');
             } else {
                 Log::info('loginByToken() User information was not updated!');
             }
             return Redirect::route($start_page, array('lang' => App::getLocale()));
         } else {
             return Redirect::route('login', array('lang' => App::getLocale()));
         }
     } else {
         return Redirect::route('login', array('lang' => App::getLocale()));
     }
 }
Example #4
0
 public function postRegistro()
 {
     $input = Input::all();
     $reglas = array('nombre' => 'required', 'apellido' => 'required', 'celular' => 'required|numeric|unique:users', 'cedula' => 'required|numeric|unique:users', 'email' => 'required|email|unique:users', 'pin' => 'required|numeric|digits_between:0,4', 'password' => 'required|numbers|case_diff|letters|min:6|confirmed', 'password_confirmation' => 'required|min:6');
     $validation = Validator::make($input, $reglas);
     if ($validation->fails()) {
         return Response::json(['success' => false, 'errors' => $validation->errors()->toArray()]);
     }
     try {
         // se guarda los datos del usuario
         $user = Sentry::register(array('first_name' => Input::get('nombre'), 'last_name' => Input::get('apellido'), 'email' => Input::get('email'), 'habilitar_pin' => 1, 'celular' => Input::get('celular'), 'cedula' => Input::get('cedula'), 'password' => Input::get('password'), 'pin' => Input::get('pin'), 'porcentaje' => 0.05, 'activated' => true));
         $userId = $user->getId();
         $token = new Token();
         $token->user_id = $userId;
         $token->api_token = hash('sha256', Str::random(10), false);
         $token->client = BrowserDetect::toString();
         $token->expires_on = Carbon::now()->addMonth()->toDateTimeString();
         $token->save();
         // Se autentica de una
         $user_login = Sentry::findUserById($userId);
         Sentry::login($user_login, false);
         return Response::json(['success' => true, 'user' => $user_login, 'token' => $token->api_token]);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         $error = array('usuario' => 'Email es requerido');
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         $error = array('usuario' => 'Password es requerido');
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         $error = array('usuario' => 'El Email ya estĆ” registrado');
     }
     return Response::json(['success' => false, 'errors' => $error]);
 }
 public function update_post($id)
 {
     $this->_exists($id);
     $rules = User::get_rules($id);
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         // Find the user using the user id
         $user = Sentry::findUserById($id);
         $user->first_name = Input::get('first_name');
         $user->last_name = Input::get('last_name');
         $user->tin_number = Input::get('tin_number');
         $user->landline = Input::get('landline');
         $user->mobile = Input::get('mobile');
         $user->work_address = json_endcode(explode(",", Input::get('work_address')));
         $user->home_address = json_endcode(explode(",", Input::get('home_address')));
         $user->company = Input::get('company');
         $user->occupation = Input::get('occupation');
         $user->email = Input::get('email');
         if (Input::get('password')) {
             $user->password = Input::get('password');
         }
         if (Input::get('activated') == 1) {
             $user->activated = true;
         } else {
             $user->activated = false;
         }
         $user->save();
         return Redirect::to('admin/clients')->with('success', 'Client account has been successfully updated.');
     }
     return Redirect::to('admin/clients/update/' . $id)->withErrors($validator)->withInput();
 }
Example #6
0
 public function pushMessage()
 {
     if (!Sentry::check()) {
         return Response::json(array('errCode' => 10, 'message' => 'čÆ·ē™»å½•'));
     }
     Sentry::login(Sentry::findUserById(5), false);
     $user = Sentry::getUser();
     // $user = User::find(1);
     $push_status = PushStatus::where('user_id', $user->id)->first();
     if (count($push_status) == 0) {
         $push_status = new PushStatus();
         $push_status->user_id = $user->id;
         $push_status->status = 1;
         if (!$push_status->save()) {
             return Response::json(array('errCode' => 1, 'message' => 'ļ¼»ę•°ę®åŗ“é”™čÆÆļ¼½å¼€åÆ궈ęÆęŽØé€å¤±č“„'));
         }
         return Response::json(array('errCode' => 0, 'message' => '开åÆ궈ęÆęŽØ送'));
     }
     if ($push_status->status == 1) {
         $push_status->status = 0;
         if (!$push_status->save()) {
             return Response::json(array('errCode' => 2, 'message' => 'ļ¼»ę•°ę®åŗ“é”™čÆÆļ¼½å¼€åÆ궈ęÆęŽØé€å¤±č“„'));
         }
         return Response::json(array('errCode' => 0, 'message' => '开åÆ궈ęÆęŽØ送'));
     }
     if ($push_status->status == 0) {
         $push_status->status = 1;
         if (!$push_status->save()) {
             return Response::json(array('errCode' => 3, 'message' => 'ļ¼»ę•°ę®åŗ“é”™čÆÆļ¼½å¼€åÆ궈ęÆęŽØé€å¤±č“„'));
         }
         return Response::json(array('errCode' => 0, 'message' => '开åÆ궈ęÆęŽØ送'));
     }
 }
Example #7
0
 public function resetPassword()
 {
     $input = Input::all();
     $user = User::where('email', '=', $input['email'])->first();
     $user = Sentry::findUserById($user->id);
     try {
         if ($user->checkResetPasswordCode($input['code'])) {
             if ($user->attemptResetPassword($input['code'], $input['password'])) {
                 $data = Citrus::response('data', 1);
                 $email = new UtilityMailman();
                 $email->setReceiver($user->email);
                 $email->setSubject('Successful Password Reset');
                 $body = $email->getBody('sreset', $user);
                 $email->setBody($body);
                 $data = $email->send($user);
             } else {
                 throw new Exception("Something is not right - please request another reset password link.");
             }
         } else {
             throw new Exception("Your reset code has expired. Please request another one.");
         }
     } catch (Exception $e) {
         $data = Citrus::response('error', $e);
     }
     return $data;
 }
 public function getGraphData()
 {
     if (Sentry::getUser()) {
         $user_id = Sentry::getUser()->id;
         $period = Input::get('check_report_period');
         $mongo_id = Input::get('report_mongo_id');
         $check_id = Input::get('report_check_id');
         $mongoAPI = new MongoAPI();
         $checkAlertEmail = new CheckAlertEmail();
         $data = json_decode($mongoAPI->getServerModelData($mongo_id, $period), true);
         $data['alert'] = $checkAlertEmail->getDataByCheckId($check_id);
         return Response::json($data);
     } else {
         try {
             $user = Sentry::findUserById(Input::get('user_id'));
             $emf_group = Sentry::findGroupByName('EmfUsers');
             if ($user->inGroup($emf_group)) {
                 return $this->get_exired_message(Config::get('kuu.emf_login_page'));
             } else {
                 return $this->get_exired_message(URL::route('login'));
             }
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             return $this->get_exired_message(URL::route('login'));
         } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
             return $this->get_exired_message(URL::route('login'));
         }
     }
 }
Example #9
0
 public static function roles($id_group, $id_user)
 {
     $user = Sentry::findUserById($id_user);
     foreach ($user->groups as $group) {
         if ($group->id == $id_group) {
             return true;
         }
     }
 }
 public function getUser($id)
 {
     try {
         $user = Sentry::findUserById($id);
         return Response::json(array('user' => $user->toArray()));
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         echo 'User was not found.';
     }
 }
 public function destroy($id)
 {
     try {
         // Find the user using the user id
         $user = Sentry::findUserById($id);
         // Delete the user
         $user->delete();
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         echo 'User was not found.';
     }
 }
Example #12
0
 public function postUlogin()
 {
     $_user = json_decode(file_get_contents('http://ulogin.ru/token.php?token=' . Input::get('token') . '&host=' . $_SERVER['HTTP_HOST']), true);
     //$user['network'] - сŠ¾Ń†. сŠµŃ‚ŃŒ, чŠµŃ€ŠµŠ· ŠŗŠ¾Ń‚Š¾Ń€ŃƒŃŽ Š°Š²Ń‚Š¾Ń€ŠøŠ·Š¾Š²Š°Š»ŃŃ ŠæŠ¾Š»ŃŒŠ·Š¾Š²Š°Ń‚ŠµŠ»ŃŒ
     //$user['identity'] - уŠ½ŠøŠŗŠ°Š»ŃŒŠ½Š°Ń стрŠ¾ŠŗŠ° Š¾ŠæрŠµŠ“ŠµŠ»ŃŃŽŃ‰Š°Ń ŠŗŠ¾Š½ŠŗрŠµŃ‚Š½Š¾Š³Š¾ ŠæŠ¾Š»ŃŒŠ·Š¾Š²Š°Ń‚ŠµŠ»Ń сŠ¾Ń†. сŠµŃ‚Šø
     //$user['first_name'] - ŠøŠ¼Ń ŠæŠ¾Š»ŃŒŠ·Š¾Š²Š°Ń‚ŠµŠ»Ń
     //$user['last_name'] - фŠ°Š¼ŠøŠ»Šøя ŠæŠ¾Š»ŃŒŠ·Š¾Š²Š°Ń‚ŠµŠ»Ń
     $validate = Validator::make([], []);
     if (isset($_user['error'])) {
         $validate->errors()->add('error', trans('larulogin::larulogin.' . $_user['error']));
         return Response::make(View::make(Config::get('larulogin::views.error'), ['errors' => $validate->errors()]), 401);
     }
     // Check exist user
     $check = Ulogin::where('identity', '=', $_user['identity'])->first();
     if ($check) {
         Auth::loginUsingId($check->user_id, true);
         if (class_exists('Sentry')) {
             $authSentry = Sentry::findUserById($check->user_id);
             Sentry::login($authSentry, true);
         }
         return Redirect::to('/');
     }
     $rules = array('network' => 'required|max:255', 'identity' => 'required|max:255|unique:ulogin', 'email' => 'required|unique:ulogin|unique:users');
     $messages = array('email.unique' => trans('larulogin::larulogin.email_already_registered'));
     $validate = Validator::make($_user, $rules, $messages);
     if ($validate->passes()) {
         $password = str_random(8);
         $user = Sentry::createUser(array('first_name' => $_user['first_name'], 'last_name' => $_user['last_name'], 'email' => $_user['email'], 'password' => $password, 'activated' => TRUE));
         foreach (Config::get('larulogin::add_to_groups') as $group_name) {
             $user->addGroup(Sentry::findGroupByName($group_name));
         }
         $ulogin = new Ulogin();
         $ulogin->user_id = $user->id;
         $ulogin->network = $_user['network'];
         $ulogin->identity = $_user['identity'];
         $ulogin->email = $_user['email'];
         $ulogin->first_name = $_user['first_name'];
         $ulogin->last_name = $_user['last_name'];
         $ulogin->photo = $_user['photo'];
         $ulogin->photo_big = $_user['photo_big'];
         $ulogin->profile = $_user['profile'];
         $ulogin->access_token = isset($_user['access_token']) ? $_user['access_token'] : '';
         $ulogin->country = isset($_user['country']) ? $_user['country'] : '';
         $ulogin->city = isset($_user['city']) ? $_user['city'] : '';
         $ulogin->save();
         $authClassic = Auth::loginUsingId($user->id);
         if (class_exists('Sentry')) {
             $authSentry = Sentry::authenticate(array('email' => $_user['email'], 'password' => $password), true);
         }
         return Redirect::to('/');
     } else {
         return Response::make(View::make(Config::get('larulogin::views.error'), array('errors' => $validate->errors())), 401);
     }
 }
Example #13
0
 public function activate($activation_code, $id)
 {
     try {
         $user = \Sentry::findUserById($id);
         $user->attemptActivation($activation_code);
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $this->errors[] = trans('auth.user_not_found');
     } catch (\Cartalyst\Sentry\Users\UserAlreadyActivatedException $e) {
         $this->errors[] = trans('auth.user_already_activated');
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function postPassClinic()
 {
     $id = Input::get('pk');
     $pass = Input::get('value');
     $user = Sentry::findUserById($id);
     $user->password = $pass;
     if ($user->save()) {
         return 'ok';
     } else {
         return 'no';
     }
 }
Example #15
0
 /**
  * Get the media_entry's editor
  * @return string
  */
 public function editor()
 {
     if ($this->updated_by == null) {
         return '';
     }
     try {
         $user = Sentry::findUserById($this->updated_by);
         return $user->username;
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return '';
     }
 }
 public function myProfile()
 {
     if (Session::get('reviewUid')) {
         $currentUser = Sentry::findUserById(Session::get('reviewUid'));
     } else {
         $currentUser = $this->user;
     }
     $this->data['item'] = $currentUser;
     $id = $currentUser->id;
     //get info publisher
     $this->data['itemPublisher'] = $this->model->with('country')->where('id', $this->getPublisher()->id)->first();
     if (Request::isMethod('post')) {
         // check validate
         $validate = Validator::make(Input::all(), $this->model->getUpdateUserRules(), $this->model->getUpdateUserLangs());
         $flag = $this->checkValidatePass($this->data);
         if ($validate->passes() && $flag == TRUE) {
             $username = Input::get('username');
             $password = Input::get('re-password');
             $firstName = Input::get('first_name');
             $lastName = Input::get('last_name');
             $email = Input::get('email');
             $updateData = ['company' => Input::get('company_name'), 'city' => Input::get('city'), 'address_contact' => Input::get('address_contact'), 'state' => Input::get('state'), 'postcode' => Input::get('postcode'), 'name_contact' => Input::get('first_name_contact'), 'email_contact' => Input::get('email_contact'), 'phone_contact' => Input::get('phone_contact')];
             //update info contact publisher
             $item = $this->model->where('id', $currentUser->publisher_id)->update($updateData);
             try {
                 $userData = Sentry::findUserById($id);
                 $userData->username = $username;
                 if ($password != "") {
                     $userData->password = $password;
                 }
                 $userData->email = $email;
                 $userData->first_name = $firstName;
                 $userData->last_name = $lastName;
                 if ($userData->save()) {
                     $data['id'] = $userData->id;
                     $messages = trans("backend::publisher/text.update_success");
                     Session::flash('msg', $messages);
                     return Redirect::to($this->moduleURL . 'profile');
                 }
             } catch (\Cartalyst\Sentry\Users\WrongPasswordException $e) {
                 $this->data['message'] = "Passwords do not exactly";
             }
         } else {
             $this->data['validate'] = $validate->messages();
         }
     }
     $this->layout->content = View::make('myProfile', $this->data);
 }
 public function generate_new_pass($hashedId)
 {
     try {
         $id = $this->hashids->decrypt($hashedId)[0];
         $user = Sentry::findUserById($id);
         $resetCode = $user->getResetPasswordCode();
         $new_password = Str::random(10);
         if ($user->attemptResetPassword($resetCode, $new_password)) {
             return View::make('backend.generate-new-pass', ["setting" => $this->setting, "success" => "Password successfully reset. Use password <strong>{$new_password}</strong> to log in"]);
         } else {
             return View::make('backend.generate-new-pass', ["error" => "Password reset failure. Kindly try again or contact admin."]);
         }
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return View::make('backend.generate-new-pass', ["error" => "User not found. Kindly try again or contact admin."]);
     }
 }
Example #18
0
 public function activateUser($activation_code, $user_id)
 {
     try {
         // Find the user using the user id
         $user = Sentry::findUserById($user_id);
         // Attempt to activate the user
         if ($user->attemptActivation($activation_code)) {
             return Redirect::to('/login')->with('global_success', 'Your profile is now active and you can sign in.');
         } else {
             return Redirect::to('/')->with('global_error', 'Activation failed, please try again or contact support.');
         }
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::to('/register')->with('global_error', 'User was not found. If you didn\'t register yet, do it now please.');
     } catch (Cartalyst\Sentry\Users\UserAlreadyActivatedException $e) {
         return Redirect::to('/login')->with('global_error', 'Your account is already active. You can sign in.');
     }
 }
Example #19
0
 public function storeUserData()
 {
     if (Sentry::check()) {
         return Response::json(array('errCode' => 0, 'message' => 'å·²ē™»å½•', 'user' => Sentry::getUser()));
     }
     //		Log::info(Input::get('data'));
     $data = json_decode(Input::get('data'));
     //	return Input::get('data');
     $user = User::where('unionid', '=', $data->unionid)->first();
     if (!isset($user)) {
         // try{
         $client_user = Sentry::createUser(array('username' => $data->nickname, 'avatar' => $data->headimgurl, 'gender' => $data->sex, 'email' => $data->unionid, 'password' => $data->unionid, 'openid' => $data->openid, 'unionid' => $data->unionid, 'activated' => '1'));
         // }
         // catch(Cartalyst\Sentry\Users\PasswordRequiredException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserExistsException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // try{
         $user = Sentry::findUserById($client_user->id);
         Sentry::login($user, false);
         // }
         // catch(Cartalyst\Sentry\Users\LoginRequiredException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserNotFoundException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserNotActivatedException $e)
         // {
         //     return View::make('errors.missing')
         // }
         return Response::json(array('errCode' => 0, 'message' => 'čæ”å›žå‚ę•°', 'user' => $user));
     }
     $user = Sentry::findUserById($user->id);
     Sentry::login($user, false);
     return Response::json(array('errCode' => 0, 'message' => 'čæ”å›žå‚ę•°', 'user' => $user));
 }
 public function getActivate($userId, $activationCode)
 {
     try {
         // Find the user using the user id
         $user = Sentry::findUserById($userId);
         // Attempt to activate the user
         if ($user->attemptActivation($activationCode)) {
             Session::flash('global', 'User Activation Successfull Please login below.');
             return Redirect::to('/user/sign/in');
         } else {
             Session::flash('global', 'Unable to activate user Try again later or contact Support Team.');
             return Redirect::to('/user/register');
         }
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         Session::flash('global', 'User was not found.');
         return Redirect::to('/user/register');
     } catch (Cartalyst\Sentry\Users\UserAlreadyActivatedException $e) {
         Session::flash('global', 'User is already activated.');
         return Redirect::to('/user/register');
     }
 }
Example #21
0
 public function activate($code)
 {
     $user = User::where('activation_code', '=', $code)->first();
     try {
         if (is_null($user)) {
             throw new Exception("There is no user with that activation code");
         }
         $user = Sentry::findUserById($user->id);
         $data = Authenticator::activate($user);
         if ($user->activated) {
             $email = new UtilityMailman();
             $email->setReceiver($user->email);
             $email->setSubject('You are now Activated!');
             $body = $email->getBody('activated');
             $email->setBody($body);
             $data = $email->send($user);
         }
     } catch (Exception $e) {
         $data = Citrus::response('error', $e);
     }
     return $data;
 }
Example #22
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     ini_set('max_execution_time', 999999999);
     $this->resetearBD();
     DB::setDefaultConnection('migracion_sasyc');
     //Se inicia sesion, es requerido en algunos eventos..
     Sentry::login(Sentry::findUserById(1));
     $this->cargarTablaNivelInstruccion();
     $this->cargarTablaParentescos('personas_sasyc');
     $this->cargarTablaParentescos('personas_familia');
     $this->migrarPersonas();
     /*$this->migrarFamiliares();
       $this->migrarRequerimientos();
       $this->migrarAreas();
       $this->migrarRecaudos();
       $this->migrarRecepciones();
       $this->migrarSolicitudes();
       $this->migrarInformeSocioEconomico();
       $this->migrarBitacora();
       $this->migrarRecaudosSolicitud();
       $this->migrarPresupuestos();*/
 }
Example #23
0
 /**
  * Process the comment, format date, set author, avatar
  *
  * @access  private
  * @param   array
  * @return  array
  */
 private function process_comment($comment)
 {
     //Get date formats from the config
     $full_date_format = isset(self::$config['full_date_format']) ? self::$config['full_date_format'] : 'M d, Y  h:i:s A';
     $short_date_format = isset(self::$config['short_date_format']) ? self::$config['short_date_format'] : FALSE;
     //Convert string date to timestamp
     $timestamp = strtotime($comment['date']);
     //Set the full date and the short date using the date formats
     $comment['date'] = date($full_date_format, $timestamp);
     $comment['short_date'] = $short_date_format ? date($short_date_format, $timestamp) : $this->datef($timestamp);
     //If the user_id exists get the user details from database
     if (!empty($comment['user_id'])) {
         /*$u = self::$config['db_users'];
         			$rows = $u['id'].','.$u['first_name'].','.$u['last_name'].','.$u['email'];
         
         			$db = new Database();
         			if ($db->select($u['table'], $rows, $u['id'].'="'.$comment['user_id'].'"', null, 1)) {
         				$user = $db->getResult(); $user = $user[1];
         				$comment['author'] = $user[$u['first_name']].' '.$user[$u['last_name']];
         
         				if ( !empty($u['avatar']) )
         					$comment['avatar'] = $user['avatar'];
         				else if ( function_exists('com_get_user_avatar') )
         					$comment['avatar'] = com_get_user_avatar( $user[$u['id']] );
         				else $comment['avatar'] = $this->gravatar( $user['email'] );
         			}*/
         $user = \Sentry::findUserById($comment['user_id']);
         $comment['author'] = $user->first_name . ' ' . $user->last_name;
         if ($user->provider == 'facebook') {
             $comment['avatar'] = 'http://graph.facebook.com/' . $user->username . '/picture?height=48&type=normal&width=48';
         } else {
             $comment['avatar'] = \URL::to('public/packages/idfluid/comments/images/noavatar.png');
         }
     } else {
         $comment['avatar'] = \URL::to('public/packages/idfluid/comments/images/noavatar.png');
     }
     $comment['reply'] = $this->config('comment_reply') ? 1 : 0;
     return $comment;
 }
Example #24
0
 public function leaderboard()
 {
     $users = User::all();
     $data = array();
     try {
         /*foreach ($users as $user) {
         				$data[$user->id] = $user->email()->count();
         			}
         			ksort($data);
         
         			//dd($user->email()->count());
         
         			$counter = 1;*/
         foreach ($users as $user) {
             $emails = $user->email()->count();
             $data[$user->id] = array('emails' => $emails, 'user' => Sentry::findUserById($user->id));
         }
         array_multisort($data, SORT_DESC);
         $response = Citrus::response('data', $data);
     } catch (Exception $e) {
         $response = Citrus::response('error', $e);
     }
     return $response;
 }
Example #25
0
 public function response()
 {
     $status = Input::get('status');
     $payment_token = Input::get('payment_token');
     $customerReferenceNo = Input::get('customerReferenceNo');
     $orderID = Input::get('orderID');
     $amount = Input::get('amount');
     $paymentMode = Input::get('paymentMode');
     $cardProvider = Input::get('cardProvider');
     $email = Input::get('email');
     $mobileNo = Input::get('mobileNo');
     $checksum = Input::get('checksum');
     $group_status = 0;
     if ($status == 0) {
         $user_id = Sentry::getUser()->id;
         $user = Sentry::findUserById($user_id);
         $sub_group = Sentry::findGroupByName('Subscribers');
         $user_group = Sentry::findGroupByName('Users');
         if ($user->removeGroup($user_group) && $user->addGroup($sub_group)) {
             $group_status = 1;
         }
     }
     return View::make('zwitch.response')->with('status', $status)->with('payment_token', $payment_token)->with('customerReferenceNo', $customerReferenceNo)->with('orderID', $orderID)->with('amount', $amount)->with('paymentMode', $paymentMode)->with('cardProvider', $cardProvider)->with('email', $email)->with('mobileNo', $mobileNo)->with('checksum', $checksum)->with('group_status', $group_status);
 }
Example #26
0
 public function postModificarPw($user_id)
 {
     $pw_actual = Input::get('pw_actual');
     try {
         // Find the user using the user id
         $input = Input::all();
         $user = Sentry::findUserById($user_id);
         $password = Input::get('password');
         if ($user->checkPassword($pw_actual)) {
             $reglas = array('password' => 'required|numbers|case_diff|letters|min:6|confirmed', 'password_confirmation' => 'required');
             $validation = Validator::make($input, $reglas);
             if ($validation->fails()) {
                 return Response::json(['success' => false, 'errors' => $validation->errors()->toArray()]);
             }
             $user->password = $password;
             $user->save();
             return Response::json(['success' => true, 'user' => $user]);
         } else {
             return Response::json(['success' => false, 'errors' => array('>>' => 'La contraseƱa actual no coincide')]);
         }
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Response::json(['success' => false, 'errors' => array('>>' => 'El usuario no existe')]);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $user = Sentry::findUserById($id);
     $user->delete();
     return Redirect::route('users.index')->with('success', 'User deleted succesfully');
 }
Example #28
0
 public function search()
 {
     $q = Input::get('q');
     try {
         $emails = Email::where('company', 'like', "%{$q}%")->get();
         foreach ($emails as $email) {
             $user = Sentry::findUserById($email->user_id);
             $email->user = $user;
         }
         $data = Citrus::response('data', $emails);
     } catch (Exception $e) {
         $data = Citrus::response('error', $e);
     }
     return $data;
 }
 public function storeUser()
 {
     $this->layout->title = APPNAME;
     if (Input::has('sid') && Input::has('email') && Input::has('pass') && !Input::has('edit-field') && strlen(Input::get('sid')) == 9) {
         $sid = Input::get('sid');
         $email = Input::get('email');
         $pass = Input::get('pass');
         $fname = Input::get('fname');
         $lname = Input::get('lname');
         try {
             // Create the user
             $user = Sentry::createUser(array('student_id' => $sid, 'email' => $email, 'password' => $pass, 'activated' => true, 'first_name' => $fname, 'last_name' => $lname));
             $permissions = Input::get('permissions');
             foreach ($permissions as $id => $permission) {
                 if ($permission == "on") {
                     $group = Sentry::findGroupById($id);
                     $user->addGroup($group);
                 }
             }
             if ($user->save()) {
                 // User information was updated
             } else {
                 // User information was not updated
             }
         } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
             echo 'Login field is required.';
         } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
             echo 'Password field is required.';
         } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
             echo 'User with this login already exists.';
         } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
             echo 'Group was not found.';
         }
         $users = Sentry::findAllUsers();
         $this->layout->content = View::make('main.admin.users')->with('users', $users);
     } elseif (Input::has('edit-field')) {
         $eid = Input::get('edit-field');
         $user = Sentry::findUserById($eid);
         $sid = Input::get('sid');
         $email = Input::get('email');
         $pass = Input::get('pass');
         $fname = Input::get('fname');
         $lname = Input::get('lname');
         $user->student_id = $sid;
         $user->email = $email;
         $user->password = $pass;
         $user->first_name = $fname;
         $user->last_name = $lname;
         $permissions = Input::get('permissions');
         $grps = Sentry::findAllGroups();
         foreach ($grps as $grp) {
             $user->removeGroup($grp);
         }
         foreach ($permissions as $id => $permission) {
             if ($permission == "on") {
                 $group = Sentry::findGroupById($id);
                 $user->addGroup($group);
             }
         }
         if ($user->save()) {
             // User information was updated
         } else {
             // User information was not updated
         }
         $users = Sentry::findAllUsers();
         $this->layout->content = View::make('main.admin.users')->with('users', $users);
     } elseif (Input::has('delid')) {
         $eid = Input::get('delid');
         $user = Sentry::findUserById($eid);
         $user->delete();
         $users = Sentry::findAllUsers();
         $this->layout->content = View::make('main.admin.users')->with('users', $users);
     }
 }
Example #30
0
 $userUpdate->last_name = $data["lastname"];
 $userUpdate->email = trim($email);
 //$data["email"];
 //$userUpdate->password = Hash::make($data["password"]);
 // Update the user table
 if ($userUpdate->save()) {
     //return dd($userUpdate);
     //break;
     // User information was updated
     //$userId = $userUpdate->id;
     if (!empty($data["password"])) {
         //if( !empty($data["password"]) || $data["password"] !== '' ) {
         try {
             // Find the user using the user email address
             //$user = Sentry::findUserByLogin($data["email"]);
             $user = Sentry::findUserById($userId);
             // Get the password reset code
             $resetCode = $user->getResetPasswordCode();
             // Now you can send this code to your user via email for example.
             // OR
             // Check if the reset password code is valid
             if ($user->checkResetPasswordCode($resetCode)) {
                 // Attempt to reset the user password
                 if ($user->attemptResetPassword($resetCode, $data["password"])) {
                     // Password reset passed
                     //echo 'Password reset passed';
                     $user->password = $data["password"];
                     $user->save();
                 } else {
                     // Password reset failed
                     echo 'Password reset failed';