Make the back-end returns the user email on login/register

This commit is contained in:
Bubka
2023-10-05 16:59:53 +02:00
parent beeaed9565
commit 9d72525b38
6 changed files with 6 additions and 0 deletions

View File

@ -114,6 +114,7 @@ class LoginController extends Controller
return response()->json([
'message' => 'authenticated',
'name' => $name,
'email' => $this->guard()->user()->email,
'preferences' => $this->guard()->user()->preferences,
'is_admin' => $this->guard()->user()->is_admin,
], Response::HTTP_OK);

View File

@ -47,6 +47,7 @@ class RegisterController extends Controller
return response()->json([
'message' => 'account created',
'name' => $user->name,
'email' => $user->email,
'preferences' => $this->guard()->user()->preferences,
'is_admin' => $this->guard()->user()->is_admin,
], 201);

View File

@ -10,6 +10,7 @@ export default async function auth({ to, next, stores }) {
if (currentUser) {
user.$patch({
name: currentUser.name,
email: currentUser.email,
preferences: currentUser.preferences,
isAdmin: currentUser.is_admin,
})

View File

@ -9,6 +9,7 @@ export const useUserStore = defineStore({
state: () => {
return {
name: undefined,
email: undefined,
preferences: window.defaultPreferences,
isAdmin: false,
}

View File

@ -32,6 +32,7 @@
.then(response => {
user.$patch({
name: response.data.name,
email: response.data.email,
preferences: response.data.preferences,
isAdmin: response.data.is_admin,
})

View File

@ -30,6 +30,7 @@
registerForm.post('/user').then(response => {
user.$patch({
name: response.data.name,
email: response.data.email,
preferences: response.data.preferences,
isAdmin: response.data.is_admin ?? false,
})