'How to change User::Model In Laravel with User Auth in Firebase
Recently I have make Laravel auth with composer require laravel/ui
and I can edit/create user with MySQL where as auth users for Firebase .
I also can create/edit Users for each database and everything is OK for now, but what I just want is to create a new user form Laravel {RegisterController}
I can create the user with Firebase, but what value or what object shall I return to be compatible with Laravel auth?
Create User with Laravel
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
Create User with FireBase
$userProperties = [
'email' => $data['email'],
'emailVerified' => false,
'password' => Hash::make($data['password']),
'displayName' => $data['name'],
];
$user = new AuthController();
return $user->Create_User($userProperties);
AuthController Class
public function __construct()
{
$this->serviceAccount=ServiceAccount::fromValue(__DIR__.'/FirebaseKey.json');
$this->firebase=(new Factory)->withServiceAccount($this->serviceAccount);
$this->auth=$this->firebase->createAuth();
}
public function Create_User($userProperties=[]){
return $this->auth->createUser($userProperties);
}
return value with dd(); -->User(Laravel)
return value with dd(); -->User(Firebase)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|