GithubHelp home page GithubHelp logo

Comments (8)

techguydev avatar techguydev commented on August 15, 2024 1

it looks like that inside the Register controller the system is not able to get the Session previous.url variable.

This is how I have managed to make it work:

In the register and login components I have set

public previewsUrl='/'
 public function Mount ()
    {
       $this->previousUrl=\Session::get('_previous.url');

    }

 public function authenticate()
    {
        $credentials = $this->validate([
            'email' => ['required', 'email'],
            'password' => ['required'],
        ]);

        if (!Auth::attempt($credentials, $this->remember)) {
            $this->addError('email', trans('auth.failed'));

            return;
        }

        redirect()->to($this->previousUrl);

    }

from tall.

daugaard47 avatar daugaard47 commented on August 15, 2024 1

@techguydev Thank you so much for solving this. That worked great.
I had to make 2 small edits:

Changed public previewsUrl='/' to public $previousUrl='/';

And then used Session like this:

public function mount ()
    {
        $this->previousUrl=\session('_previous.url');
    }

Works perfect for Login and Registration!
Thanks Again!

from tall.

ryangjchandler avatar ryangjchandler commented on August 15, 2024

Hi @techguydev - the Livewire components with this preset are published so you can just change the redirect in the Login component class to redirect()->back() instead of redirect(route('home'))

from tall.

imliam avatar imliam commented on August 15, 2024

On this note I've just changed the default behaviour to redirect to the intended route after login and registration #50

from tall.

techguydev avatar techguydev commented on August 15, 2024

Thanks @imliam I appreciate it.

from tall.

techguydev avatar techguydev commented on August 15, 2024

@imliam I have tried making the changes you suggested but it is not redirecting to the previos page

from tall.

techguydev avatar techguydev commented on August 15, 2024

it is just not working for me I even try to test if there is some session info in the mount method of the register component and it always returns null @ryangjchandler @imliam

from tall.

techguydev avatar techguydev commented on August 15, 2024

@daugaard47 nice to hear it worked for you too.

from tall.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.