Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

Commit

Permalink
Fix unneeded uniqueness check
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReverend403 committed Apr 8, 2016
1 parent 8be8582 commit fac779a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/Http/Controllers/Account/PreferencesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@ public function get()

public function post(Request $request)
{
$validator = Validator::make($request->all(), [
$rules = [
'timezone' => 'required|timezone',
'pagination-items' => 'required|min:3|max:100|integer',
'email' => 'required|email|max:255|unique:users',
]);
];

// Allow the validator to pass the uniqueness check if the email hasn't changed
if ($request->input('email') === Auth::user()->email) {
$rules['email'] = 'required|email|max:255';
}

$validator = Validator::make($request->all(), $rules);

if ($validator->fails()) {
return redirect()->route('account.preferences')
Expand Down

0 comments on commit fac779a

Please sign in to comment.