From 44e477a9e1c700ec536d3be614feed014415e60f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 10 May 2017 13:02:20 +0300 Subject: [PATCH] Multi-db fixes --- app/Http/Controllers/UserController.php | 2 +- app/Models/AccountToken.php | 8 +++++--- app/Models/Contact.php | 8 +++++--- app/Models/Invitation.php | 8 +++++--- app/Models/LookupUser.php | 1 + app/Models/User.php | 9 ++++++--- 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 0df9c05e7c06..6cce8ec58fc1 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -182,7 +182,7 @@ class UserController extends BaseController ->withInput(); } - if (! \App\Models\LookupUser::validateEmail($email, $user)) { + if (! \App\Models\LookupUser::validateEmail(Input::get('email'), $user)) { return Redirect::to($userPublicId ? 'users/edit' : 'users/create') ->withError(trans('texts.email_taken')) ->withInput(); diff --git a/app/Models/AccountToken.php b/app/Models/AccountToken.php index 0196c64f47f4..3a2922161e30 100644 --- a/app/Models/AccountToken.php +++ b/app/Models/AccountToken.php @@ -50,7 +50,9 @@ AccountToken::creating(function ($token) AccountToken::deleted(function ($token) { - LookupAccountToken::deleteWhere([ - 'token' => $token->token - ]); + if ($token->forceDeleting) { + LookupAccountToken::deleteWhere([ + 'token' => $token->token + ]); + } }); diff --git a/app/Models/Contact.php b/app/Models/Contact.php index adc0fa752beb..0e9c719f56aa 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -176,7 +176,9 @@ Contact::creating(function ($contact) Contact::deleted(function ($contact) { - LookupContact::deleteWhere([ - 'contact_key' => $contact->contact_key, - ]); + if ($contact->forceDeleting) { + LookupContact::deleteWhere([ + 'contact_key' => $contact->contact_key, + ]); + } }); diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php index 1447ff4da9f1..c3d142e8cb5d 100644 --- a/app/Models/Invitation.php +++ b/app/Models/Invitation.php @@ -173,7 +173,9 @@ Invitation::creating(function ($invitation) Invitation::deleted(function ($invitation) { - LookupInvitation::deleteWhere([ - 'invitation_key' => $invitation->invitation_key, - ]); + if ($invitation->forceDeleting) { + LookupInvitation::deleteWhere([ + 'invitation_key' => $invitation->invitation_key, + ]); + } }); diff --git a/app/Models/LookupUser.php b/app/Models/LookupUser.php index 6d829fa48428..18703aa90fea 100644 --- a/app/Models/LookupUser.php +++ b/app/Models/LookupUser.php @@ -17,6 +17,7 @@ class LookupUser extends LookupModel 'lookup_account_id', 'email', 'user_id', + 'confirmation_code', ]; public static function updateUser($accountKey, $userId, $email, $confirmationCode) diff --git a/app/Models/User.php b/app/Models/User.php index aa960865b3ab..5cce5fd27162 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -418,6 +418,7 @@ User::created(function ($user) LookupUser::createNew($user->account->account_key, [ 'email' => $user->email, 'user_id' => $user->id, + 'confirmation_code' => $user->confirmation_code, ]); }); @@ -440,7 +441,9 @@ User::deleted(function ($user) return; } - LookupUser::deleteWhere([ - 'email' => $user->email - ]); + if ($user->forceDeleting) { + LookupUser::deleteWhere([ + 'email' => $user->email + ]); + } });