DEV Community

Discussion on: Auth0 with Laravel 5.4 including saving the user

Collapse
 
ophasnoname profile image
Arne

It's implemented in the UserRepository:

    protected function upsertUser($profile) {

        $user = User::where("auth0id", $profile->user_id)->first();

        // create user if not in database
        if ($user === null) {
            $user = new User();
            $user->email = $profile->email;
            $user->auth0id = $profile->user_id;
            $user->name = $profile->name;
            $user->password = md5(time());
            $user->save();
        }

        return $user;
    }