Laravel: redirect after logging in

Asked

Viewed 63 times

0

Hey, guys, what’s up? I’m sending an email to the customer like this:

@component('mail::button', ['url' => env('APP_URL') .'/SobeDocsFiadorCadastrado/'. $fiador->id ])
Clique para iniciar
@endcomponent

However, the system obviously asks for the login credentials and after passing them, I need the user to be directed to the route that is on the button, but instead, he goes home.

Here’s the piece of Logincontroller’s code that takes care of it:

public function login(Request $request)
    {
        $credentials = $this->credentials($request);
        $login = $credentials[$this->username()];
        $cpfCnpjHigienizado = str_replace('-', '', str_replace('/', '', (str_replace('.', '', $request->cpfCnpj))));
        $credenciais = User::where('cpfCnpj', '=', $cpfCnpjHigienizado)->first();
        if ($credenciais) { // Se já estiver cadastro, vai pra home
            Auth::login($credenciais);
            return redirect(route('SobeDocsFiador'))->withFiador($request->fiador);
            // return redirect(route('home'));
        } else {
            //////////////////////////////////////////////////////// INICIO LOGIN NOS WS

-> a partir desse ponto, sei que o não é cadastrado e vai fazer outra coisa

Anyway, how do I redirect to the URL I send by email? I’ve tried a return $request->all(); to see what returns after login ,but stop $fiador->id won’t come...

2 answers

1


  • Very good indeed Allan, thank you! But it is not by scrolling that I want to redirect, but by route, for example: I sent an email to the user to go to the route 'Sobedocsfiador'. Only first he has to log in and then be redirected to this route. Only he won’t... he goes home

0

I solved using the method

compact('credenciais')

Now he asks for the login and then goes to the right route that is:

Route::get('SobeDocsFiadorCadastrado/{id}', 'DocumentoController@SobeDocsFiadorCadastrado')->name('SobeDocsFiadorCadastrado');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.