Example #1
0
 public function buscarUserbyEmail($input_buscar, $mi_email)
 {
     $user_que_solicita = User::where('email', $mi_email)->first();
     $findUserByCedula = User::where('cedula', $input_buscar)->where('cedula', '<>', 0)->first();
     // buscar por # de cedula
     if (empty($findUserByCedula)) {
         // buscar por email
         try {
             $findUserByEmail = Sentry::findUserByLogin($input_buscar);
             // valida que su email no sea el mismo que va a buscar
             if ($mi_email == $findUserByEmail->email) {
                 return Response::json(['success' => false, 'msg' => 'No, se puede buscar a usted mismo']);
             }
             return Response::json(['success' => true, 'user' => $findUserByEmail]);
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             return Response::json(['success' => false, 'msg' => 'El usuario no se encontró, en la base de datos']);
         }
     } else {
         // valida que su cedula no sea la misma que va a buscar
         if ($user_que_solicita->cedula == $input_buscar) {
             return Response::json(['success' => false, 'msg' => 'No, se puede buscar a usted mismo']);
         } else {
             return Response::json(['success' => true, 'user' => $findUserByCedula]);
         }
     }
 }
Example #2
0
 public function resetAction()
 {
     // Fetch all request data.
     $data = Input::only('email', 'password', 'password_confirmation', 'pass_code');
     // Build the validation constraint set.
     $rules = array('email' => array('required'), 'password' => array('required', 'confirmed', 'min:5'));
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $user = Sentry::findUserByLogin(Input::get('email'));
         // Check if the reset password code is valid
         if ($user->checkResetPasswordCode(Input::get('pass_code'))) {
             // Attempt to reset the user password
             if ($user->attemptResetPassword(Input::get('pass_code'), Input::get('password'))) {
                 $user->reset_password_code = '';
                 $user->save();
                 return Redirect::to('/login')->with('global_success', 'Password has been set. You can now sign in with your new password.');
             } else {
                 return Redirect::to('/reset')->with('global_error', 'System couldn\'t change your password. Please try again and if situation repeats, report to support.');
             }
         } else {
             return Redirect::to('/request')->with('global_error', 'Your reset code doesn\'t match. It may be corrupted or outdated. Please make a new request.');
         }
     }
     return Redirect::to('/reset/' . Input::get('pass_code'))->withErrors($validator)->with('message', 'Validation Errors!');
 }
 public function postResetPassword()
 {
     /* ----------------validate data ------------------- */
     $email = preg_replace('/\\s+/', '', Input::get('email'));
     $validation = array('email' => 'required|email');
     $validator = Validator::make(array('email' => $email), $validation);
     if ($validator->fails()) {
         return Redirect::to('user/reset-password')->withInput()->withErrors($validator);
     }
     /* --------check if user exists------------------- */
     try {
         // Find the user using the user email address
         $user = Sentry::findUserByLogin($email);
         // Get the password reset code
         $reset_code = $user->getResetPasswordCode();
         //            $url = "http://domain.com/reset-password-form.php?id=" . $user['id'] . '&timestamp=' . $time . '&hash=' . $hash;
         //            send_email($email, 'reset password email from xxx.com', ' Please click the following link to reset password' . $url);
         $data = array('id' => $user->id, 'email' => $email, 'reset_code' => $reset_code);
         //            $this->sendResetPasswordMail($data);
         $ret = MailCustom::get()->sendResetPasswordMail($data);
         if ($ret[0]) {
             return Redirect::back()->with('msg', 'A password reset link was sent to your email.')->with('state', '1');
         } else {
             return Redirect::back()->withInput()->with('msg', 'failed to send email')->with('state', '-1');
         }
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::back()->withInput()->with('msg', 'User was not found.')->with('state', '-1');
     }
 }
 /**
  * Impersonate an admin
  *
  */
 public function beAdmin()
 {
     $admin = Sentry::findUserByLogin('*****@*****.**');
     Sentry::setUser($admin);
     Session::put('userId', 1);
     Session::put('email', '*****@*****.**');
 }
 public function run()
 {
     // Wipe the table clean before populating
     DB::table('user_meta')->truncate();
     $entries = array(array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'username' => 'rob', 'location' => 'Hawaii', 'website' => 'http://rob.bertholf.com', 'title' => '@Rob', 'bio' => 'Its the Rob'), array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'username' => 'superuser', 'location' => 'Hawaii', 'website' => 'http://saasventure.com', 'title' => 'Really Super', 'bio' => 'Super... Really'), array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'username' => 'foo', 'location' => 'Hawaii', 'website' => 'http://saasventure.com', 'title' => 'Not so Super', 'bio' => 'Not so... Really'));
     // Run the seeder
     DB::table('user_meta')->insert($entries);
 }
 /**
  * A basic fixture test example
  *
  * @return void
  */
 public function testBasicFixture()
 {
     $user = Sentry::findUserByLogin('*****@*****.**');
     $this->assertEquals('Benevolent', $user->first_name);
     $this->assertEquals('Dictator', $user->last_name);
     $brand = Groups::getBrandProvider()->findByTitle('BizGym');
     $this->assertTrue(Groups::isAdmin($user->id, $brand->id));
 }
 public function run()
 {
     // Refresh Brand_user_groups
     DB::table('group_user_brand')->truncate();
     $entries = array(array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'group_id' => Sentry::findGroupByName('Admin')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('BizGym')->id), array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'group_id' => Sentry::findGroupByName('User')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('SaaS Venture Group')->id), array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'group_id' => Sentry::findGroupByName('Admin')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('BizGym')->id), array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'group_id' => Sentry::findGroupByName('User')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('SaaS Venture Group')->id));
     // Uncomment the below to run the seeder
     DB::table('group_user_brand')->insert($entries);
 }
Example #8
0
 /**
  * Account sign in form processing.
  *
  * @return Redirect
  */
 public function postSignin()
 {
     // Declare the rules for the form validation
     $rules = array('username' => 'required', 'password' => 'required');
     // Create a new validator instance from our validation 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::back()->withInput()->withErrors($validator);
     }
     try {
         /**
          * =================================================================
          * Hack in LDAP authentication
          */
         // Try to get the user from the database.
         $user = (array) DB::table('users')->where('username', Input::get('username'))->first();
         if ($user && strpos($user["notes"], 'LDAP') !== false) {
             LOG::debug("Authenticating user against LDAP.");
             if ($this->ldap(Input::get('username'), Input::get('password'))) {
                 LOG::debug("valid login");
                 $pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10);
                 $user = Sentry::findUserByLogin(Input::get('username'));
                 $user->password = $pass;
                 $user->save();
                 $credentials = array('username' => Input::get('username'), 'password' => $pass);
                 Sentry::authenticate($credentials, Input::get('remember-me', 0));
             } else {
                 throw new Cartalyst\Sentry\Users\UserNotFoundException();
             }
         } else {
             LOG::debug("Authenticating user against database.");
             // Try to log the user in
             Sentry::authenticate(Input::only('username', 'password'), Input::get('remember-me', 0));
         }
         // Get the page we were before
         $redirect = Session::get('loginRedirect', 'account');
         // Unset the page we were before from the session
         Session::forget('loginRedirect');
         // Redirect to the users page
         return Redirect::to($redirect)->with('success', Lang::get('auth/message.signin.success'));
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $this->messageBag->add('username', Lang::get('auth/message.account_not_found'));
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $this->messageBag->add('username', Lang::get('auth/message.account_not_activated'));
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         $this->messageBag->add('username', Lang::get('auth/message.account_suspended'));
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         $this->messageBag->add('username', Lang::get('auth/message.account_banned'));
     }
     // Ooops.. something went wrong
     return Redirect::back()->withInput()->withErrors($this->messageBag);
 }
 public function test_user_status_attribute_can_be_banned()
 {
     // Find the user we are going to suspend
     $user = Sentry::findUserByLogin('*****@*****.**');
     // Fetch the User Repository
     $userRepository = app()->make('Sentinel\\Repositories\\User\\SentinelUserRepositoryInterface');
     // Suspend the user
     $result = $userRepository->ban($user->id);
     $this->assertInstanceOf('Cartalyst\\Sentry\\Throttling\\Eloquent\\Throttle', $user->throttle);
     $this->assertEquals('Banned', $user->status);
 }
 /**
  * Test the two basic user types
  *
  */
 public function testBasicUserTypes()
 {
     $this->assertTrue(Sentry::getUser() == NULL, 'User should not be logged in initially.');
     $admin = Sentry::findUserByLogin($this->adminEmail);
     $this->assertTrue($admin != NULL, 'Admin account not found.');
     $user = Sentry::findUserByLogin($this->userEmail);
     $this->assertTrue($user != NULL, 'User account not found.');
     Sentry::setUser($user);
     $this->assertTrue(Sentry::check(), 'User not logged in.');
     Sentry::setUser($admin);
     $this->assertTrue(Sentry::check(), 'Admin not logged in.');
     Sentry::logout();
 }
 public function getCodigo($email)
 {
     try {
         $user = Sentry::findUserByLogin($email);
         $resetCode = $user->getResetPasswordCode(5);
         $data = array('codigo' => $resetCode);
         Mail::queue('emails.resetpw', $data, function ($message) use($user) {
             $message->from('*****@*****.**', 'Bancoink');
             $message->to($user->email, $user->first_name)->subject('Reset Password!');
         });
         return Response::json(['success' => true, 'codigo' => $resetCode]);
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $error = 'El email no está registrado';
         return Response::json(['success' => false, 'error' => $error]);
     }
 }
Example #12
0
 public function forgotPassword()
 {
     $email = Input::get('email', false);
     if ($email && filter_var($email, FILTER_VALIDATE_EMAIL)) {
         try {
             $user = Sentry::findUserByLogin($email);
             Mail::send('emails.auth.reminder', ['token' => $user->getResetPasswordCode()], function ($message) use($user) {
                 $message->to($user->email, $user->username)->subject('Password reset request !');
             });
             return Response::json([], 200);
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             return Response::json(['flash' => 'No user has been found with this email'], 400);
         }
     }
     return Response::json(['flash' => 'A valid email must be provided'], 400);
 }
 public function run()
 {
     // Refresh user groups
     DB::table('group_user_system')->truncate();
     // Assign administrator user to admin group
     try {
         $rob = Sentry::findUserByLogin('*****@*****.**');
         $rob->addGroup(Sentry::findGroupByName('Admin'));
         $administrator = Sentry::findUserByLogin('*****@*****.**');
         $administrator->addGroup(Sentry::findGroupByName('Admin'));
         $foo = Sentry::findUserByLogin('*****@*****.**');
         $foo->addGroup(Sentry::findGroupByName('User'));
     } catch (Exception $e) {
         // If we need to stop it, then we could just throw it
         // throw $e;
     }
 }
Example #14
0
 /**
  * Create root user and basic permission structure in the database.
  * For detailed documentation on permission structure, see
  * PermissionHandler class.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     // Create admin user with admin permisions
     Sentry::getUserProvider()->create(['_id' => ProjectHandler::ADMIN_USER, 'password' => 'admin', 'email' => '*****@*****.**', 'firstname' => 'Admin', 'lastname' => 'Crowdtruth']);
     // Create the admin group with special permission Permissions::ALLOW_ALL
     ProjectHandler::createGroup('admin');
     $adminGroup = Sentry::findGroupByName('admin:admin');
     $permissions = $adminGroup->permissions;
     $permissions[Permissions::ALLOW_ALL] = 1;
     // Allowed everything !
     $adminGroup->permissions = $permissions;
     $adminGroup->save();
     // Assign user admin to group admin.
     $root = Sentry::findUserByLogin(ProjectHandler::ADMIN_USER);
     $root->addGroup($adminGroup);
 }
Example #15
0
 public function askPermission()
 {
     $provider = new League\OAuth2\Client\Provider\Facebook(array('clientId' => '372319239612356', 'clientSecret' => '8c78a15dfaa0bf16a81191b68ec89638', 'redirectUri' => 'http://www.subbly.dev/auth'));
     if (!isset($_GET['code'])) {
         // If we don't have an authorization code then get one
         header('Location: ' . $provider->getAuthorizationUrl());
         exit;
     } else {
         // Try to get an access token (using the authorization code grant)
         $token = $provider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
         // Optional: Now you have a token you can look up a users profile data
         try {
             // We got an access token, let's now get the user's details
             $userDetails = $provider->getUserDetails($token);
             // Use these details to create a new profile
             printf('Hello %s!', $userDetails->firstName);
         } catch (Exception $e) {
             // Failed to get user details
             exit('Oh dear...');
         }
         try {
             // Find the user using the user id
             $user = Sentry::findUserByLogin($userDetails->email);
             // Log the user in
             Sentry::login($user, false);
             // return Redirect::route('home');
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             // Register the user
             $user = Sentry::register(array('activated' => 1, 'email' => $userDetails->email, 'password' => Hash::make(uniqid(time())), 'first_name' => $userDetails->firstName));
             // $usergroup = Sentry::getGroupProvider()->findById(2);
             // $user->addGroup($usergroup);
             Sentry::login($user, false);
             // return Redirect::route('account');
         }
         Debugbar::info($userDetails);
         Debugbar::info($user);
         // exit;
         // Use this to interact with an API on the users behalf
         echo $token->accessToken;
         // Use this to get a new access token if the old one expires
         echo $token->refreshToken;
         // Number of seconds until the access token will expire, and need refreshing
         echo $token->expires;
     }
 }
Example #16
0
 public function post_remember_password()
 {
     $email = Input::get('email');
     try {
         $user = Sentry::findUserByLogin($email);
         $resetCode = $user->getResetPasswordCode();
         $input = array('id' => $user->id, 'reset_code' => $resetCode, 'root' => $this->root);
         $callback = function ($message) use($user) {
             $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Reset password');
         };
         Mail::send(array('html' => 'emails.reset_password'), $input, $callback);
         return $this->make_response($email, false, array('Richiesta di modifica password inviata correttamente'), URL::to('/'));
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return $this->make_response($email, true, array('Utente non trovato'));
     } catch (\Exception $e) {
         return $this->make_response($email, true, array("Errore non previsto: " . $e->getMessage()));
     }
 }
Example #17
0
 public function loginGithub()
 {
     $code = Input::get('code');
     $email = Input::get('email');
     $github = OAuth::consumer('GitHub');
     if (!empty($email)) {
         $user = User::where('email', '=', $email)->first();
         if (isset($user)) {
             Session::flash('warning', trans('user.register.social.already-exists'));
             return Redirect::route('user.register');
         }
         $user = Sentry::createUser(array('email' => $email, 'password' => md5(time() . uniqid()), 'activated' => true));
         UserGitHub::create(array('user_id' => $user->id, 'access_token' => Input::get('access_token'), 'refresh_token' => !empty(Input::get('refresh_token')) ? Input::get('refresh_token') : null, 'end_of_life' => !empty(Input::get('end_of_life')) ? Input::get('end_of_life') : null));
         $user = Sentry::findUserByLogin($user->email);
         Sentry::login($user, false);
         Session::flash('success', trans('user.register.social.success'));
         return Redirect::route('home');
     } elseif (empty($code)) {
         $url = $github->getAuthorizationUri(array('state' => md5(time() . uniqid()), 'redirect_uri' => URL::route('user.login.github')));
         return Response::make()->header('Location', (string) $url);
     } else {
         $token = $github->requestAccessToken($code);
         $emails = json_decode($github->request('/user/emails'), true);
         if (!is_array($emails) || count($emails) === 0) {
             Session::flash('error', trans('user.register.social.no-emails'));
             return Redirect::route('user.register');
         }
         if (count($emails) <= 1) {
             $user = User::where('email', '=', $emails[0])->first();
             if (isset($user)) {
                 Session::flash('warning', trans('user.register.social.already-exists'));
                 return Redirect::route('user.register');
             }
             $user = Sentry::createUser(array('email' => $emails[0], 'password' => md5(time() . uniqid()), 'activated' => true));
             UserGitHub::create(array('user_id' => $user->id, 'access_token' => $token->getAccessToken(), 'refresh_token' => !empty($token->getRefreshToken()) ? $token->getRefreshToken() : null, 'end_of_life' => !empty($token->getEndOfLife()) ? $token->getEndOfLife() : null));
             Sentry::login($user, false);
             Session::flash('success', trans('user.register.social.success'));
             return Redirect::route('home');
         }
         return View::make('user.social', array('emails' => $emails, 'token' => $token));
     }
 }
Example #18
0
 public function facebookLogin()
 {
     // get data from input
     $code = \Input::get('code');
     $redirect = $this->currentURL(\Input::get('url-back'));
     // get fb service
     $fb = \OAuth::consumer('Facebook');
     // check if code is valid
     // if code is provided get user data and sign in
     if (!empty($code)) {
         // This was a callback request from facebook, get the token
         $token = $fb->requestAccessToken($code);
         // Send a request with it
         $result = json_decode($fb->request('/me'), true);
         try {
             $user = \Sentry::findUserByLogin($result['email']);
             if ($user) {
                 // Log the user in
                 \Sentry::login($user, false);
                 return \Redirect::to($redirect);
             } else {
                 $register = \Sentry::createUser(array('first_name' => $result['first_name'], 'last_name' => $result['last_name'], 'username' => $result['username'], 'provider' => 'facebook', 'email' => $result['email'], 'password' => $result['email'], 'activated' => true));
                 if ($register) {
                     $login = \Sentry::findUserById($register->id);
                     // Log the user in
                     \Sentry::login($login, false);
                     return \Redirect::to($redirect);
                 } else {
                     return \Redirect::to($redirect)->with('message', 'The following errors occurred')->withErrors($validator)->withInput();
                 }
             }
         } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
             echo 'Wrong password, try again.';
         }
     } else {
         // get fb authorization
         $url = $fb->getAuthorizationUri();
         // return to facebook login url
         return \Redirect::to((string) $url);
     }
 }
 public function GET_loginUser()
 {
     try {
         // Login credentials
         $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'));
         $find_user = Sentry::findUserByLogin($credentials['email']);
         if ($find_user) {
             // Authenticate the user
             $user = Sentry::authenticateAndRemember($credentials, false);
         }
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         $msg = 'Login field is required.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         $msg = 'Password field is required.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         $msg = 'Wrong password, try again.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $msg = 'User was not found.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $msg = 'User is not activated.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         $msg = 'User is suspended.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         $msg = 'User is banned.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     }
     $group_admin = Sentry::findGroupByName('Administrator');
     if ($user->inGroup($group_admin)) {
         return Redirect::to(route('admin'));
     } else {
         return Redirect::to(route('home'));
     }
 }
Example #20
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($data)
 {
     $result = array();
     $data['email'] = strtolower($data['email']);
     try {
         // Check for 'rememberMe' in POST data
         if (!array_key_exists('rememberMe', $data)) {
             $data['rememberMe'] = 0;
         }
         // Set login credentials
         $credentials = array('email' => e($data['email']), 'password' => e($data['password']));
         // Try to authenticate the user
         $user = $this->sentry->authenticate($credentials, e($data['rememberMe']));
         $result['success'] = true;
         $result['sessionData']['userId'] = $user->id;
         $result['sessionData']['email'] = $user->email;
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         // Sometimes a user is found, however hashed credentials do
         // not match. Therefore a user technically doesn't exist
         // by those credentials. Check the error message returned
         // for more information.
         $result['success'] = false;
         $result['message'] = trans('sessions.invalid');
     } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $result['success'] = false;
         $url = route('resendActivationForm', ['email' => $data['email']]);
         $user = \Sentry::findUserByLogin($data['email']);
         if ($user->activated_at) {
             $result['message'] = trans('users.deactivated');
         } else {
             $result['message'] = trans('sessions.notactive', array('url' => $url));
         }
     } catch (\Cartalyst\Sentry\Throttling\UserBannedException $e) {
         $result['success'] = false;
         $result['message'] = trans('sessions.banned');
     }
     //Login was succesful.
     return $result;
 }
Example #21
0
 public function forgot()
 {
     if (Sentry::check()) {
         return Redirect::route('admin.dashboard');
     }
     if (Request::isMethod('post')) {
         try {
             $input = Input::all();
             $data = User::where('email', $input['email'])->first();
             $user = Sentry::findUserByLogin($data->username);
             $code = $user->getResetPasswordCode();
             $param = ['user' => $user, 'code' => $code];
             Mail::send('administrator.mail.forgot', $param, function ($message) use($user) {
                 $message->to($user->email, $user->full_name)->subject('Recuperar Contraseña');
             });
             return Redirect::route('admin.forgot')->with('success', 'Revisa tu email, te enviamos los pasos para tu contraseña.');
         } catch (Exception $e) {
             return Redirect::route('admin.forgot')->with('message', $e->getMessage());
         }
     }
     return View::make('administrator.forgot', ['title' => 'Recuperar Contraseña']);
 }
 public function postLogin()
 {
     try {
         $user = Sentry::findUserByLogin(Input::get('email'));
         $groups = $user->getGroups();
         if ($groups != '[]') {
             if ($groups[0]->name == 'Administrador') {
                 try {
                     $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'));
                     $user = Sentry::authenticate($credentials, false);
                     return Redirect::to('admin/home');
                 } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
                     return Redirect::back()->with('message', 'Login field is required.');
                 } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
                     return Redirect::back()->with('message', 'Password field is required.');
                 } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
                     return Redirect::back()->with('message', 'Wrong password, try again.');
                 } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
                     return Redirect::back()->with('message', 'User was not found.');
                 } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
                     return Redirect::back()->with('message', 'User is not activated.');
                 } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
                     return Redirect::back()->with('message', 'User is suspended.');
                 } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
                     return Redirect::back()->with('message', 'User is banned.');
                 }
             } else {
                 return Redirect::back()->with('message', 'Error');
                 //usuario queiere ingresar por aca
             }
         } else {
             return Redirect::back()->with('message', 'Error');
             //usuario queiere ingresar por aca
         }
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::back()->with('message', 'Error');
     }
 }
Example #23
0
 public function run()
 {
     DB::table('users')->delete();
     DB::table('groups')->delete();
     DB::table('users_groups')->delete();
     $user = Sentry::createUser(array('email' => '*****@*****.**', 'password' => "admin", 'first_name' => 'John', 'last_name' => 'Nguyen', 'activated' => 1, 'phone' => '123456789', 'skype' => 'skypename', 'sex' => 'male', 'avatar' => 'public/images/avatar.png', 'profile' => "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"));
     $user = Sentry::createUser(array('email' => '*****@*****.**', 'password' => "support", 'first_name' => 'John', 'last_name' => 'McClane', 'activated' => 1, 'phone' => '123456789', 'skype' => 'skypename', 'sex' => 'male', 'avatar' => 'public/images/avatar4.png', 'profile' => "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"));
     $user2 = Sentry::createUser(array('email' => '*****@*****.**', 'password' => "member", 'first_name' => 'Bruce', 'last_name' => 'Wayne', 'activated' => 1, 'phone' => '23564586', 'skype' => 'skypename', 'sex' => 'male', 'avatar' => 'public/images/avatar2.png', 'profile' => "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"));
     $groupAdmin = Sentry::createGroup(array('name' => 'administer', 'permissions' => array('administer' => 1)));
     $groupSup = Sentry::createGroup(array('name' => 'supporter', 'permissions' => array('supporter' => 1)));
     $groupMember = Sentry::createGroup(array('name' => 'user', 'permissions' => array('user' => 1)));
     // Assign user permissions
     $adminUser = Sentry::findUserByLogin('*****@*****.**');
     $adminGroup = Sentry::findGroupByName('administer');
     $adminUser->addGroup($adminGroup);
     // Assign user permissions
     $spUser = Sentry::findUserByLogin('*****@*****.**');
     $spGroup = Sentry::findGroupByName('supporter');
     $spUser->addGroup($spGroup);
     $mUser = Sentry::findUserByLogin('*****@*****.**');
     $mGroup = Sentry::findGroupByName('user');
     $mUser->addGroup($mGroup);
 }
 /**
  * admin.comments.message
  *
  */
 public function postAdminMessage()
 {
     if (Input::has('email') && Input::has('answer') && Input::has('description')) {
         $email = Input::get('email');
         $sentry = Sentry::findUserByLogin($email);
         $idComment = Input::get('idComment');
         $data['email'] = $email;
         $data['first_name'] = $sentry->first_name;
         $data['last_name'] = $sentry->last_name;
         $data['answer'] = Input::get('answer');
         $data['description'] = Input::get('description');
         $comment = $this->comment->selectComment($idComment);
         $comment->status = 0;
         if ($comment->save()) {
             Mail::send('emails.comments.message', $data, function ($m) use($data) {
                 $m->to($data['email'])->subject('Gracias por comentar - Support Team ART');
             });
         }
         return Redirect::route('admin.comments.index')->with(['message' => 'Ha sido enviado la respuesta al Email: ' . $email, 'class' => 'success']);
     } else {
         return Redirect::route('admin.comments.index')->with(['message' => 'ERROR TEAM: llamar al 968159823', 'class' => 'danger']);
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //GET
     $redir = $this->check();
     if ($redir) {
         return $redir;
     } else {
         $this->layout->title = APPNAME;
         if ($id == "edit") {
             $user = Sentry::getUser();
             $programs = Program::all();
             $this->layout->content = View::make('main.profile.edit')->with('user', $user)->with('programs', $programs);
         } else {
             try {
                 //  $currentuser = Sentry::getUser();
                 $user = Sentry::findUserByLogin($id);
                 $userprograms = $user->programs();
             } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
                 echo 'User was not found.';
             }
             $this->layout->content = View::make('main.profile.index')->with('user', $user);
         }
     }
 }
Example #26
0
 /**
  * Simpan password user yang baru
  * @param string $token
  * @return response
  */
 public function storeNewPassword()
 {
     try {
         // Cari user berdasarkan email
         $user = Sentry::findUserByLogin(Input::get('email'));
         // Check apakah resetCode valid
         if ($user->checkResetPasswordCode(Input::get('resetCode'))) {
             // Validasi password baru
             $rules = array('password' => 'confirmed|required|min:5');
             $validator = Validator::make($data = Input::all(), $rules);
             // Redirect jika validasi gagal
             if ($validator->fails()) {
                 return Redirect::back()->withErrors($validator)->withInput();
             }
             // Reset password user
             $user->attemptResetPassword(Input::get('resetCode'), Input::get('password'));
             return Redirect::to('login')->with('successMessage', 'Berhasil me-reset password. Silahkan login dengan password baru.');
         } else {
             return Redirect::to('login')->with('errorMessage', 'Reset code tidak valid.');
         }
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::to('login')->with('errorMessage', $e->getMessage());
     }
 }
 public function testUnbanUser()
 {
     // Find the user we are going to suspend
     $user = Sentry::findUserByLogin('*****@*****.**');
     // Prepare the Throttle Provider
     $throttleProvider = Sentry::getThrottleProvider();
     // Ban the user
     $this->repo->ban($user->id);
     // This is the code we are testing
     $result = $this->repo->unban($user->id);
     // Ask the Throttle Provider to gather information for this user
     $throttle = $throttleProvider->findByUserId($user->id);
     // Check the throttle status.  This should do nothing.
     $throttle->check();
     // Assertions
     $this->assertTrue($result->isSuccessful());
 }
 public function doUserLoginBySocial()
 {
     try {
         $user = Sentry::findUserByLogin(Input::get('email'));
     } catch (UserNotFoundException $e) {
         $isEmailVerified = $this->doCreateUser();
         $data = array('status' => $isEmailVerified, 'error' => 'Осталось только подтвердить имейл, перейдя по ссылке из письма');
         return Response::json($data);
     }
     if ($user->isActivated()) {
         User::login($user);
     }
     $data = array('status' => $user->isActivated(), 'error' => 'Сначала нужно подтвердить имейл, перейдя по ссылке из письма');
     return Response::json($data);
 }
Example #29
0
@extends('layouts.login')
@section('content')

<div id="wrapper">
<div id="content">
<div id="form-wrapper">



@foreach($record as $records)
<?php 
$user = Sentry::findUserByLogin($records->email);
$staff_id = $user->id;
?>

{{ Form::open(array('url' =>'dashboard/agencystaff/'.$records->agency_id.'/edit/'.$staff_id,'files' => true,'POST')) }}

 <h1>Agency Staff </h1>
 <p class="erorclas"> {{ Session::get('errors') }}</p>
    <ul>
    
     <h2>User Details</h2>
        <li>
            {{ Form::label('email', 'Email') }}
            {{ Form::text('email',$records->email) }}
        </li>



        <li>
            {{ Form::label('name', 'Name') }}
 /**
  * new.password.post
  *
  */
 public function postNewPassword()
 {
     $rules = array('password' => 'required|min:6|max:32', 're_password' => 'required|min:6|max:32|same:password');
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->passes()) {
         if (Input::has('email') && Input::has('resetcode')) {
             try {
                 $sentry = Sentry::findUserByLogin(Input::get('email'));
                 if ($sentry->checkResetPasswordCode(Input::get('resetcode'))) {
                     if ($sentry->attemptResetPassword(Input::get('resetcode'), Input::get('password'))) {
                         return Redirect::route('signin')->with('mensaje', 'Cambio de contraseña fue un éxito. Por favor ingresa abajo con su nueva contraseña.')->with('class', 'success');
                     } else {
                         return Redirect::route('forgot.password')->with('mensaje', 'No se ha podido restablecer la contraseña. Por favor, inténtalo de nuevo.')->with('class', 'danger');
                     }
                 } else {
                     return Redirect::route('forgot.password')->with('mensaje', 'No se ha podido restablecer la contraseña. Por favor, vuelva a intentarlo.')->with('class', 'danger');
                 }
             } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
                 return Redirect::route('forgot.password')->with('mensaje', 'Usuario no encontrado.')->with('class', 'danger');
             }
         } else {
             return Redirect::route('forgot.password')->with('mensaje', 'Solicitud no válida. Introduzca correo electrónico para restablecer su contraseña.')->with('class', 'danger');
         }
     } else {
         return Redirect::to('/new/password?email=' . Input::get('email') . '&resetcode=' . Input::get('resetcode'))->withErrors($validation)->withInput();
     }
 }