From 3dfdcb84bd5e200050ee62521e9c891158be00d5 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Mon, 27 Jan 2020 22:04:47 +0100 Subject: [PATCH] Update username after Profile update --- app/Http/Controllers/UserController.php | 5 ++++- resources/js/views/profile/Edit.vue | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index de395054..c7522324 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -132,7 +132,10 @@ public function update(Request $request) tap($user)->update($request->only('name', 'email')); - return response()->json(['message' => __('auth.forms.profile_saved')]); + return response()->json([ + 'message' => __('auth.forms.profile_saved'), + 'username' => $request->name + ]); } diff --git a/resources/js/views/profile/Edit.vue b/resources/js/views/profile/Edit.vue index 03faec99..f97650a9 100644 --- a/resources/js/views/profile/Edit.vue +++ b/resources/js/views/profile/Edit.vue @@ -92,6 +92,8 @@ .then(response => { this.response = response.data.message + + localStorage.setItem('user',response.data.username) }) .catch(error => { if( error.response.status === 400 ) {