Skip to content

Commit

Permalink
Added defensive check onto user's language after creating
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanhao Li authored and ifox committed Mar 2, 2020
1 parent 664cd63 commit 07ddbdb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Repositories/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,15 @@ public function prepareFieldsBeforeSave($user, $fields)
public function afterSave($user, $fields)
{
$this->sendWelcomeEmail($user);
$language = $fields['language'];
if ($language !== config('twill.locale')) {
$user->language = $language;
$user->save();

if (isset($fields['language'])) {
$language = $fields['language'];
if ($language !== config('twill.locale')) {
$user->language = $language;
$user->save();
}
}

parent::afterSave($user, $fields);
}

Expand Down

0 comments on commit 07ddbdb

Please sign in to comment.