public function postLogin() { try { $credentials = array('email' => Input::get('email'), 'password' => Input::get('password')); $user = Sentry::authenticate($credentials, false); if ($user->isActivated()) { Sentry::loginAndRemember($user); return Response::json(array('code' => '1', 'info' => 'Login successful.', 'id' => $user->id)); } else { return Response::json(array('code' => '0', 'info' => 'User is invalid.')); } } catch (\Exception $ex) { return Response::json(array('code' => '0', 'error' => $ex, 'info' => 'Username/Password is not correct.')); } }
public function postLogin() { $credentials = array('email' => Input::get('email'), 'password' => Input::get('password')); try { $user = Sentry::authenticate($credentials, false); if ($user) { if (Input::get('remember') == 'true') { Sentry::loginAndRemember($user); } } } catch (\Exception $e) { return Redirect::route('home'); // View::make('hello')->withErrors(array('login' => $e->getMessage()));; } try { Sentry::login($user, false); } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) { echo 'Login field is required.'; } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) { echo 'User not activated.'; } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { echo 'User not found.'; } }
public function action_login_complete($view = array('throttle' => '')) { if ($this->request->post() != null) { $view = array('throttle' => ''); try { $throttle_provider = Sentry::getThrottleProvider(); //if the login throttler is enabled set it up if (Kohana::$config->load('sentry.throttle') == true) { $throttle_provider->enable(); $throttle = $throttle_provider->findByUserLogin($this->request->post('email')); //set the limit of consecutive failed login attempts $throttle->setAttemptLimit(Kohana::$config->load('sentry.throttle_attempts')); //set the suspension time in minutes $throttle->setSuspensionTime(Kohana::$config->load('sentry.throttle_suspension_time')); } else { $throttle_provider->disable(); } $user = Sentry::getUserProvider()->findByCredentials(array('email' => $this->request->post('email'), 'password' => $this->request->post('password'))); // Log the user in if ($this->request->post('remember', false)) { Sentry::loginAndRemember($user); } else { Sentry::login($user, false); } //if the login throttler is enabled clear failed login attempts if ($throttle_provider->isEnabled()) { $throttle->clearLoginAttempts(); } Hint::set(Hint::SUCCESS, 'Welcome back!'); //everything went successful, send the user somewhere else $this->redirect(Route::url('S4K.users.login', null, true)); //@todo you'll probably rather send your user to a welcome page than back to the login } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) { Hint::set(Hint::ERROR, 'You seem to have have provided an incorrect password.'); //if throttles are enabled add an attempt and show how many attempts are left if ($throttle_provider->isEnabled()) { $throttle->addLoginAttempt(); $view['throttle'] = $throttle->getLoginAttempts() . '/' . $throttle->getAttemptLimit() . ' attempts left.'; } } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { Hint::set(Hint::ERROR, 'There\'s no user with that login.'); } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) { Hint::set(Hint::ERROR, 'We need to know who\'s logging in.'); } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) { Hint::set(Hint::ERROR, 'Your account hasn\'t been activated yet.'); } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) { $time = $throttle->getSuspensionTime(); Hint::set(Hint::ERROR, 'You have tried logging in too much, wait ' . $time . ' minutes before trying again.'); } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) { Hint::set(Hint::ERROR, 'You are banned.'); } //No success signing in, show the form again with the errors $this->_tpl->hints = Hint::render(null, true, 's4k/hint'); $this->action_login($view); } else { // no post request made, send back $this->redirect(Route::url('S4K.users.login', null, true)); } }
try { // We got an access token, let's now get the user's details $userDetails = $provider->getUserDetails($token); try { // Find the user using the user email address $user = Sentry::findUserByLogin($userDetails->email); Sentry::loginAndRemember($user); return Redirect::to('me'); // Now you can send this code to your user via email for example. } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { $user = Sentry::createUser(array('email' => $userDetails->email, 'password' => Str::random(40), 'first_name' => $userDetails->firstName, 'last_name' => $userDetails->lastName, 'activated' => true)); // Find the group using the group id $userGroup = Sentry::findGroupById(1); // Assign the group to the user $user->addGroup($userGroup); Sentry::loginAndRemember($user); return Redirect::to('me'); } // Use these details to create a new profile //printf('Hello %s!', $userDetails->firstName); } catch (Exception $e) { // Failed to get user details exit($e->getMessage()); } } }); //rotue tester Route::get('/thumb', function () { $path = '/home/xtwoend/Video/hunterxhunter.mp4'; $destination = '/home/xtwoend/Video/'; $name = 'dadang.jpg';