I am trying to correctly set the clock device in my application.
I can log in and out and protect the routes, but I cannot get redirect::intended to work correctly. I understand that the user will be returned to the route that they initially call before being redirected to the login page. At the moment, it is simply redirecting to the default page.
In my route.php, I have the following group installed:
Route::group(array('before' => 'sentryAuth'), function () {...}
In this group I placed all protected routes.
In my filters.php, I have the following filters:
Route::filter('sentryAuth', function () { if (!Sentry::check()) { return Redirect::route('login'); } });
Route :: filter ('sentryGuest', function () {
if (Sentry::check()) { return Redirect::intended('dashboard'); } });
In my userController, I have the following code:
public function postAuthenticate() { try { // Set login credentials $credentials = array( 'email' => Input::get('email'), 'password' => Input::get('password') ); // Try to authenticate the user $user = Sentry::authenticate($credentials, false); } 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\UserNotFoundException $e) { echo 'User was not found.'; } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) { echo 'Wrong password, try again.'; } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) { echo 'User is not activated.'; } if (!Sentry::check()) { return Redirect::to('user/login'); } else { return Redirect::intended('dashboard'); } }
I tried to access the booking / creation page without logging in. I get to the login page, log in, but then it brings me to the control panel, and does not order / creates.
AM Am I missing something? Is there any additional code I need to get it working?
authentication laravel cartalyst-sentry
Ray
source share