From d1023faeb44a9f4efa0dc2e29d3d4e3239034f84 Mon Sep 17 00:00:00 2001 From: jack Date: Thu, 31 May 2018 09:56:15 +0800 Subject: [PATCH] fix update profile error fix update profile frontend unauthorize --- app/Company.php | 2 +- app/Http/Controllers/AuthController.php | 3 ++- public/verify-code-number.html | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Company.php b/app/Company.php index ee6bb6c..237e5cc 100644 --- a/app/Company.php +++ b/app/Company.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; class Company extends Model { // - protected $fillable = ['company_profile', 'reg_cert', 'company_name', 'registration_no', 'tax_no', 'tel_no', 'fax', 'address', 'city', 'postcode', 'state', 'country', 'contact_person']; + protected $fillable = ['user_id', 'company_profile', 'reg_cert', 'company_name', 'registration_no', 'tax_no', 'tel_no', 'fax', 'address', 'city', 'postcode', 'state', 'country', 'contact_person']; //protected $guarded = []; public function user() diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 17ba3f3..24b22a0 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -149,8 +149,9 @@ class AuthController extends Controller // TODO : create company for user $company = new Company; - $company->user = $user; + $company->user_id = $user->id; $company->save(); + return response()->json(['success'=> true, 'message'=> 'Profile updated.']); } diff --git a/public/verify-code-number.html b/public/verify-code-number.html index 02cc3c1..0cec4a1 100644 --- a/public/verify-code-number.html +++ b/public/verify-code-number.html @@ -78,8 +78,8 @@ token: $('#verify-code').val()}, success: function(data) { if( data.success){ + localStorage.token = data.token; document.location.href="profile-first-setup.html"; - localStorage.token = data.data.token; } else{ console.log('wrong code');