1

Which classes to use for caching certain token or url? After login, I want the user to redirect two urls back in Laravel 4.2? I have tried already with URlGenerator and Request class in my User authentification function so I could catch my previous url which is GET request for login, while the desired url is before this request.

My login function:

namespace \Users\Repositories;

use View , Input , Redirect , Config;
use Illuminate\Routing\UrlGenerator;
use Users\Repositories\Contracts\AuthRepositoryInterface;
use Illuminate\Support\MessageBag;
use Illuminate\Http\Request;




class AuthRepository implements AuthRepositoryInterface {

    private $messageBag;
    private $errors;
    private $urlGenerator;
    private $request;


    public function __construct(MessageBag $messageBag, UrlGenerator $urlGenerator, Request $request) {
        $this->messageBag    = $messageBag;
        $this->urlGenerator  = $urlGenerator;
        $this->request       = $request;
    }

 public function postLogin() {

        $remember_me = (Input::get('remember_me') == 1 ? true : false);


        try
        {
            // Login credentials
            $credentials = array(
                'email'    => Input::get('email'),
                'password' => Input::get('password'),
            );


            // Authenticate the user
            $user = \Sentry::authenticate($credentials, $remember_me);

            // giving example
            //if(token or url)
            //redirect to 'frontend.fee.registration'
            //else

            return Redirect::route('profile')->with('success' , trans('users::success.login_success'));


        }

My routes:

 Route::get( '/login' ,                              array( 'as' => 'login' , 'uses' => 'HomeController@userLogin' ) );
Route::post('/login' ,                              array( 'as' => 'postLogin' , 'uses' => '\Users\Controllers\AuthController@postLogin' ) );

Redirect destination:

Route::get('/fee/{id}/register/'  ,                 array( 'as' => 'frontend.fee.registration' ,    'uses' => 'FeeController@feeRegistration' ) );
ajax_27
  • 63
  • 7

1 Answers1

0

There is no built in solution, but you can use session to save current URLs and then use them to go back 2-3-4 etc pages back.

Look at the answer and the code here: How to return back twice in Laravel?

Community
  • 1
  • 1
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279