Skip to content

Problem with normal laravel user table #4

Closed
@patekuru

Description

@patekuru

There are a couple of problems i had with this:

Auth0::onLogin(function($auth0User) {
// See if the user exists
$user = User::where("auth0id", $auth0User->user_id)->first();
if ($user === null) {
// If not, create one
$user = new User();
$user->email = $auth0User->email;
$user->auth0id = $auth0User->user_id;
$user->nickname = $auth0User->nickname;
$user->name = $auth0User->name;
$user->save();
}
return $user;
});

Upon the 2nd user created in thus manner, there is an error because normal laravel user tables have a unique username column.
Creating the 2nd user with the username '' as per above code, causes the problem.
I solved this simply by dropping the username column from the table.
Is that ok? If so you should mention that in the docs.

If have OLD users from BEFORE when you installed the "laravel-auth0" (aka "login") package, where the auth0id = ''.
The above code will log you in as the first user in the database even if you're not logged in because $auth0User->user_id == ''.
Perhaps fix by adding something like
if ($auth0User->user_id != '') { }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions