Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ljwjulian's avatar

Laravel 8 with Breeze, setted the existing user table for Auth, but doesn't work

I have to build a new system with a kind of old-style pre-existing MySQL database tables with Laravel 8 with Breeze. Already have a user data table that is totally different from the basic Auth system in Laravel 8. I am trying to figure out to make Auth system but it doesn't work right.

This is my User model class.

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;

    protected $table = 'tb_user_info';

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var array<int, string>
     */
    protected $hidden = [
        //'passwd',
        'remember_token',
    ];

    public function setPasswordAttribute($password)
    {
        $this->attributes['passwd'] = \DB::raw("password('$password')");
    }
    public function getAuthPassword()
    {
        return $this->passwd;
    }
}

And this is my store method in AuthenticatedSessionController, which I figured it is using in login.

public function store(LoginRequest $request)
    {
        $credentials = $request->validate([
            'mem_id' => ['required', 'email'],
            'passwd' => ['required'],
        ]);

       $user = User::select('mem_id', 'passwd')->where('mem_id', $request->mem_id)->first();
        if ($user->mem_id == $request->mem_id && $user->passwd == $this->sql_password($request->passwd)) {
            $request->session()->regenerate();

            return redirect('/dashboard');
        }

        return back()->withErrors([
            'mem_id' => 'The provided credentials do not match our records.',
        ]);
    }

I thought it simply works, but after I try to login, it doesn't work at all, just keep redirecting back to the login page. I looked up the Network tab in Chrome, it seems like the dashboard page was called but it shows 302 Found and called the login page again.

Which part should I lookup for this situation? I am working on this for 3 days, nothing came up for a good solution. Please, please help me, I would be appreciated just a few tips.

Ps. Please don't answer like stop using the MySQL password for password or why don't you make a new database table? because it's meaningless answers. I would do that already if I can. This is a very limited situation at work. Please understand.

0 likes
8 replies
jlrdw's avatar

@ljwjulian you can, you just have to tweak the logic. Breeze is better suited for a brand new project.

I suggest watching some of the free videos where he covers Authentication.

jlrdw's avatar

@ljwjulian He is @jeffreyway the owner of this site and he does Laracasts videos.

Breeze is setup like:

    public function store(LoginRequest $request)
    {
        $request->authenticate();
        $request->session()->regenerate();
		return redirect(RouteServiceProvider::HOME);
    }

Study the breeze code (flow) and understand how it works. And at this line:

return redirect(RouteServiceProvider::HOME);

You can set a custom redirect instead.

1 like
ljwjulian's avatar

@jlrdw ok thank you. But I also figured the method is used in Breeze, that's why I modified the method as I wrote here above. And I also checked the RouteServiceProvider, which doesn't make difference at all.

ljwjulian's avatar

Any better solution for this problem? T_T

Please or to participate in this conversation.