Skip to content

Commit

Permalink
generating a verification token if the field is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
MelonSmasher committed Jul 13, 2017
1 parent 30df538 commit 206f312
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/Http/Controllers/API/V1/EmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ public function store(Request $request)
if ($toRestore = Email::onlyTrashed()->where('address', $data['address'])->first()) $toRestore->restore();
$trans = new EmailTransformer();
$item = Email::updateOrCreate(['address' => $data['address']], $data);
$item->verification_token = ($item->verified) ? null : generateVerificationToken();

if (!$item->verified || empty($item->verification_token)) {
$item->verification_token = generateVerificationToken();
}

$item->save();

// Start verification if we can and if it's needed
Expand Down

0 comments on commit 206f312

Please sign in to comment.