From 4a54544756769394bfad6f68b9055b95cb6a38ac Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Mon, 27 Aug 2018 21:28:44 +0100 Subject: [PATCH 1/7] #99: Added a basic user profile settings screen --- .../Controllers/Gallery/UserController.php | 7 ++ resources/lang/en/gallery.php | 5 ++ resources/lang/en/navigation.php | 3 +- .../base/gallery/user_settings.blade.php | 70 +++++++++++++++++++ .../themes/base/partials/navbar.blade.php | 3 +- routes/web.php | 10 ++- 6 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 resources/views/themes/base/gallery/user_settings.blade.php diff --git a/app/Http/Controllers/Gallery/UserController.php b/app/Http/Controllers/Gallery/UserController.php index 014420b..f1bbecf 100644 --- a/app/Http/Controllers/Gallery/UserController.php +++ b/app/Http/Controllers/Gallery/UserController.php @@ -15,6 +15,13 @@ use Symfony\Component\HttpFoundation\Request; class UserController extends Controller { + public function settings(Request $request) + { + return Theme::render('gallery.user_settings', [ + 'user' => $this->getUser() + ]); + } + public function show(Request $request, $idOrAlias) { // If a user has a profile alias set, their profile page cannot be accessed by the ID diff --git a/resources/lang/en/gallery.php b/resources/lang/en/gallery.php index c2b6384..bd23787 100644 --- a/resources/lang/en/gallery.php +++ b/resources/lang/en/gallery.php @@ -77,5 +77,10 @@ return [ 'cameras' => 'Cameras', 'no_albums_p1' => 'No Photo Albums', 'no_albums_p2' => ':user_name has not created any albums yet.' + ], + 'user_settings' => [ + 'change_password' => 'Change password', + 'show_public_profile' => 'Allow others to see my profile page', + 'title' => 'Change my settings' ] ]; \ No newline at end of file diff --git a/resources/lang/en/navigation.php b/resources/lang/en/navigation.php index dc352b7..28ce905 100644 --- a/resources/lang/en/navigation.php +++ b/resources/lang/en/navigation.php @@ -36,6 +36,7 @@ return [ 'public_profile_page' => 'My public profile', 'quick_post' => 'Quick Upload', 'register' => 'Register', - 'statistics' => 'Statistics' + 'statistics' => 'Statistics', + 'user_settings' => 'Change my settings' ] ]; \ No newline at end of file diff --git a/resources/views/themes/base/gallery/user_settings.blade.php b/resources/views/themes/base/gallery/user_settings.blade.php new file mode 100644 index 0000000..983efc9 --- /dev/null +++ b/resources/views/themes/base/gallery/user_settings.blade.php @@ -0,0 +1,70 @@ +@extends(Theme::viewName('layout')) +@section('title', trans('gallery.user_settings.title')) + +@section('content') +
+
+
+
+
+ +
+
+
+ {{ csrf_field() }} + {{ method_field('PUT') }} + +
+ + +
+ + + @if ($errors->has('name')) +
+ {{ $errors->first('name') }} +
+ @endif +
+
+ +
+ + +
+ + + @if ($errors->has('email')) +
+ {{ $errors->first('email') }} +
+ @endif +
+
+ + + +
+ is_admin)) checked="checked"@endif> + +
+ +
+ @lang('forms.cancel_action') + +
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/themes/base/partials/navbar.blade.php b/resources/views/themes/base/partials/navbar.blade.php index bd3b2a3..369ba68 100644 --- a/resources/views/themes/base/partials/navbar.blade.php +++ b/resources/views/themes/base/partials/navbar.blade.php @@ -78,8 +78,9 @@ -
+ -
- is_admin)) checked="checked"@endif> - -
+
+ Public profile -
+
+ + +
+ + @lang('forms.profile_alias_help') + + @if ($errors->has('profile_alias')) +
+ {{ $errors->first('profile_alias') }} +
+ @endif +
+
+ +
+
+
+ enable_profile_page)) checked="checked"@endif> + +
+
+
+
+ +
@lang('forms.cancel_action')
From e4863af668c8e5c7a23596db2d31591c24d19a9a Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Fri, 7 Sep 2018 09:03:21 +0100 Subject: [PATCH 3/7] #5: Don't show the "alternatively..." message when no social media providers are configured --- resources/views/themes/base/partials/login.blade.php | 3 +-- resources/views/themes/base/partials/register.blade.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/resources/views/themes/base/partials/login.blade.php b/resources/views/themes/base/partials/login.blade.php index 542302d..d2c46fe 100644 --- a/resources/views/themes/base/partials/login.blade.php +++ b/resources/views/themes/base/partials/login.blade.php @@ -2,9 +2,8 @@ @if (UserConfig::isSocialMediaLoginEnabled())

@lang('auth.social_login')

@include(Theme::viewName('partials.social_login_providers')) +

@lang('auth.email_password_login')

@endif - -

@lang('auth.email_password_login')

@else

@lang('auth.email_password_login_sso')

@lang('auth.email_password_login_sso_2')

diff --git a/resources/views/themes/base/partials/register.blade.php b/resources/views/themes/base/partials/register.blade.php index 8e7157e..06608aa 100644 --- a/resources/views/themes/base/partials/register.blade.php +++ b/resources/views/themes/base/partials/register.blade.php @@ -2,9 +2,8 @@ @if (UserConfig::isSocialMediaLoginEnabled())

@lang('auth.social_register')

@include(Theme::viewName('partials.social_login_providers')) +

@lang('auth.email_password_register')

@endif - -

@lang('auth.email_password_register')

@else

@lang('auth.email_password_register_sso')

@endif From 929237ef905e3d4ee469e0051f883f2551ed5782 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Fri, 7 Sep 2018 10:05:38 +0100 Subject: [PATCH 4/7] #99: User settings are now saving. Still need to implement validation on the profile name and e-mail verification for the new e-mail address. --- .../Controllers/Gallery/UserController.php | 23 +++++++++++++ app/Http/Requests/SaveUserSettingsRequest.php | 33 +++++++++++++++++++ resources/lang/en/gallery.php | 1 + .../base/gallery/user_settings.blade.php | 1 - routes/web.php | 2 +- 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 app/Http/Requests/SaveUserSettingsRequest.php diff --git a/app/Http/Controllers/Gallery/UserController.php b/app/Http/Controllers/Gallery/UserController.php index f1bbecf..a8ae63f 100644 --- a/app/Http/Controllers/Gallery/UserController.php +++ b/app/Http/Controllers/Gallery/UserController.php @@ -7,6 +7,7 @@ use App\Facade\Theme; use App\Facade\UserConfig; use App\Helpers\DbHelper; use App\Http\Controllers\Controller; +use App\Http\Requests\SaveUserSettingsRequest; use App\User; use Illuminate\Support\Collection; use Illuminate\Support\Facades\App; @@ -15,9 +16,31 @@ use Symfony\Component\HttpFoundation\Request; class UserController extends Controller { + public function saveSettings(SaveUserSettingsRequest $request) + { + $data = $request->only(['name', 'email', 'profile_alias', 'enable_profile_page']); + + if (UserConfig::get('require_email_verification')) + { + // Can't update the e-mail directly until the new e-mail address has been verified. + // TODO - send e-mail and handle response, flag e-mail as being "change in-progress" + unset($data['email']); + } + + $user = $this->getUser(); + $user->fill($data); + $user->enable_profile_page = (isset($data['enable_profile_page']) && strtolower($data['enable_profile_page']) == 'on'); + $user->save(); + + $request->session()->flash('success', trans('gallery.user_settings.settings_saved')); + + return redirect(route('userSettings')); + } + public function settings(Request $request) { return Theme::render('gallery.user_settings', [ + 'success' => $request->session()->get('success'), 'user' => $this->getUser() ]); } diff --git a/app/Http/Requests/SaveUserSettingsRequest.php b/app/Http/Requests/SaveUserSettingsRequest.php new file mode 100644 index 0000000..0c664f2 --- /dev/null +++ b/app/Http/Requests/SaveUserSettingsRequest.php @@ -0,0 +1,33 @@ + 'required|max:255', + 'email' => 'required|email|max:255|unique:users,email,' . Auth::user()->id + // TODO include user profile alias + ]; + } +} \ No newline at end of file diff --git a/resources/lang/en/gallery.php b/resources/lang/en/gallery.php index b782b31..b1f1b6b 100644 --- a/resources/lang/en/gallery.php +++ b/resources/lang/en/gallery.php @@ -80,6 +80,7 @@ return [ ], 'user_settings' => [ 'change_password' => 'Change password', + 'settings_saved' => 'Your settings were updated successfully.', 'title' => 'Change my settings' ] ]; \ No newline at end of file diff --git a/resources/views/themes/base/gallery/user_settings.blade.php b/resources/views/themes/base/gallery/user_settings.blade.php index 962ce1e..5c8e8b8 100644 --- a/resources/views/themes/base/gallery/user_settings.blade.php +++ b/resources/views/themes/base/gallery/user_settings.blade.php @@ -16,7 +16,6 @@
{{ csrf_field() }} - {{ method_field('PUT') }}
diff --git a/routes/web.php b/routes/web.php index 99d1315..3bc1377 100644 --- a/routes/web.php +++ b/routes/web.php @@ -120,6 +120,6 @@ Route::get('u/{idOrAlias}', 'Gallery\UserController@show') Route::get('me/settings', 'Gallery\UserController@settings') ->name('userSettings') ->middleware('auth'); -Route::get('me/save-settings', 'Gallery\UserController@saveSettings') +Route::post('me/save-settings', 'Gallery\UserController@saveSettings') ->name('saveUserSettings') ->middleware('auth'); \ No newline at end of file From 5a042476210fa24bd44b3977623ce21a4aed3fff Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Wed, 12 Sep 2018 14:27:34 +0100 Subject: [PATCH 5/7] #99: Started working on e-mail address activation when changed using the user settings page --- .../Controllers/Gallery/UserController.php | 26 ++++++++++- app/Mail/UserChangeEmailRequired.php | 46 +++++++++++++++++++ ...2_142055_add_user_email_change_columns.php | 36 +++++++++++++++ resources/lang/en/auth.php | 2 + resources/lang/en/email.php | 3 ++ resources/lang/en/forms.php | 1 + .../user_change_email_required.blade.php | 17 +++++++ .../base/gallery/user_settings.blade.php | 2 +- 8 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 app/Mail/UserChangeEmailRequired.php create mode 100644 database/migrations/2018_09_12_142055_add_user_email_change_columns.php create mode 100644 resources/views/themes/base/email/user_change_email_required.blade.php diff --git a/app/Http/Controllers/Gallery/UserController.php b/app/Http/Controllers/Gallery/UserController.php index a8ae63f..3809354 100644 --- a/app/Http/Controllers/Gallery/UserController.php +++ b/app/Http/Controllers/Gallery/UserController.php @@ -8,10 +8,12 @@ use App\Facade\UserConfig; use App\Helpers\DbHelper; use App\Http\Controllers\Controller; use App\Http\Requests\SaveUserSettingsRequest; +use App\Mail\UserChangeEmailRequired; use App\User; use Illuminate\Support\Collection; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Mail; use Symfony\Component\HttpFoundation\Request; class UserController extends Controller @@ -19,15 +21,36 @@ class UserController extends Controller public function saveSettings(SaveUserSettingsRequest $request) { $data = $request->only(['name', 'email', 'profile_alias', 'enable_profile_page']); + $user = $this->getUser(); if (UserConfig::get('require_email_verification')) { // Can't update the e-mail directly until the new e-mail address has been verified. // TODO - send e-mail and handle response, flag e-mail as being "change in-progress" + // Send activation e-mail + + // Temporarily change the e-mail address so we can send the activation message + $oldEmailAddress = $user->getEmailForPasswordReset(); + $user->email = $data['email']; + + Mail::to($this->getUser())->send(new UserChangeEmailRequired($this->getUser())); + $request->session()->flash('info', trans('auth.change_email_required_message')); + + // Flag the user as a change e-mail in progress + $user->new_email_address = $user->email; + $user->is_email_change_in_progress = true; + $user->email = $oldEmailAddress; + $user->save(); + + unset($data['email']); + } + + // Don't allow e-mail address to be changed if a change is in progress + if ($user->is_email_change_in_progress) + { unset($data['email']); } - $user = $this->getUser(); $user->fill($data); $user->enable_profile_page = (isset($data['enable_profile_page']) && strtolower($data['enable_profile_page']) == 'on'); $user->save(); @@ -40,6 +63,7 @@ class UserController extends Controller public function settings(Request $request) { return Theme::render('gallery.user_settings', [ + 'info' => $request->session()->get('info'), 'success' => $request->session()->get('success'), 'user' => $this->getUser() ]); diff --git a/app/Mail/UserChangeEmailRequired.php b/app/Mail/UserChangeEmailRequired.php new file mode 100644 index 0000000..6f39a27 --- /dev/null +++ b/app/Mail/UserChangeEmailRequired.php @@ -0,0 +1,46 @@ +user = $user; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + $subject = trans('email.change_email_required_subject', ['app_name' => UserConfig::get('app_name')]); + + return $this + ->subject($subject) + ->markdown(Theme::viewName('email.user_change_email_required')) + ->with([ + 'subject' => $subject, + 'user' => $this->user + ]); + } +} diff --git a/database/migrations/2018_09_12_142055_add_user_email_change_columns.php b/database/migrations/2018_09_12_142055_add_user_email_change_columns.php new file mode 100644 index 0000000..727bf75 --- /dev/null +++ b/database/migrations/2018_09_12_142055_add_user_email_change_columns.php @@ -0,0 +1,36 @@ +boolean('is_email_change_in_progress')->default(false); + $table->string('new_email_address')->nullable(true); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) + { + $table->dropColumn('is_email_change_in_progress'); + $table->dropColumn('new_email_address'); + }); + } +} diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index 545f1b6..8ba7e21 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -20,6 +20,8 @@ return [ 'and password you provided when you registered.', 'activation_required_message' => 'An e-mail containing an activation link has been sent to the e-mail address you provided. ' . 'Please click the link in this e-mail to activate your account.', + 'change_email_required_message' => 'An e-mail containing an activation link has been sent to the e-mail address you provided. ' . + 'Please click the link in this e-mail to confirm your new e-mail address.', 'change_password_action' => 'Change password', 'change_password_title' => 'Change your password', 'email_password_login' => 'Alternatively, login with your e-mail address and password:', diff --git a/resources/lang/en/email.php b/resources/lang/en/email.php index 698bc6a..15d7776 100644 --- a/resources/lang/en/email.php +++ b/resources/lang/en/email.php @@ -4,6 +4,9 @@ return [ 'activation_required_p2' => 'To confirm your e-mail address and activate your account, please click the link below. ' . 'You may also need to copy + paste this into your browser\'s address bar if your e-mail reader has split this line.', 'activation_required_subject' => 'Activate your :app_name account', + 'change_email_required_p1' => 'A change was requested to your e-mail address on :app_name.', + 'change_email_required_p2' => 'To confirm this e-mail address is valid and update the e-mail address on your account, please click the button below.', + 'change_email_required_subject' => 'Confirm the e-mail change to your :app_name account', 'generic_intro' => 'Hi :user_name,', 'generic_regards' => 'Regards,', 'test_email_subject' => 'Test e-mail from :app_name' diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index d040f4b..b96752f 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -14,6 +14,7 @@ return [ 'bulk_edit_photos_placeholder' => 'Select an action', 'cancel_action' => 'Cancel', 'close_action' => 'Close', + 'confirm_email_action' => 'Confirm e-mail address', 'continue_action' => 'Continue', 'create_action' => 'Create', 'create_album_label' => 'Create a new album:', diff --git a/resources/views/themes/base/email/user_change_email_required.blade.php b/resources/views/themes/base/email/user_change_email_required.blade.php new file mode 100644 index 0000000..62018b6 --- /dev/null +++ b/resources/views/themes/base/email/user_change_email_required.blade.php @@ -0,0 +1,17 @@ +@component('mail::message') +@lang('email.generic_intro', ['user_name' => $user->name]) + + +@lang('email.change_email_required_p1', ['app_name' => UserConfig::get('app_name')]) + + +@lang('email.change_email_required_p2') + +@component('mail::button', ['url' => route('auth.activate', ['token' => $user->activation_token]), 'color' => 'blue']) + @lang('forms.confirm_email_action') +@endcomponent + +@lang('email.generic_regards')
+{{ UserConfig::get('app_name') }}
+{{ route('home') }} +@endcomponent \ No newline at end of file diff --git a/resources/views/themes/base/gallery/user_settings.blade.php b/resources/views/themes/base/gallery/user_settings.blade.php index 5c8e8b8..5bfc8b3 100644 --- a/resources/views/themes/base/gallery/user_settings.blade.php +++ b/resources/views/themes/base/gallery/user_settings.blade.php @@ -35,7 +35,7 @@
- + is_email_change_in_progress ? ' readonly="readonly"' : '' }}> @if ($errors->has('email'))
From 2e0e98810a5d327c7e51a4239bb271f28fc4bd5d Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Wed, 12 Sep 2018 17:08:27 +0100 Subject: [PATCH 6/7] #99: Email address can now be changed and confirmed with registration --- .../Controllers/Gallery/UserController.php | 72 ++++++++++++++++--- resources/lang/en/auth.php | 3 +- resources/lang/en/gallery.php | 3 + .../user_change_email_required.blade.php | 2 +- .../base/gallery/user_settings.blade.php | 13 +++- routes/web.php | 6 ++ 6 files changed, 88 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Gallery/UserController.php b/app/Http/Controllers/Gallery/UserController.php index 3809354..12e4714 100644 --- a/app/Http/Controllers/Gallery/UserController.php +++ b/app/Http/Controllers/Gallery/UserController.php @@ -18,31 +18,78 @@ use Symfony\Component\HttpFoundation\Request; class UserController extends Controller { + public function confirmEmailChangeState(Request $request) + { + $user = $this->getUser(); + if (!$user->is_email_change_in_progress) + { + return redirect(route('userSettings')); + } + + // Update the e-mail address + $user->email = $user->new_email_address; + + // Reset the e-mail change state + $user->is_email_change_in_progress = false; + $user->new_email_address = null; + $user->save(); + + $request->session()->flash('success', trans('auth.change_email_success_message')); + return redirect(route('userSettings')); + } + + public function resetEmailChangeState(Request $request) + { + $user = $this->getUser(); + if (!$user->is_email_change_in_progress) + { + return redirect(route('userSettings')); + } + + $data = $request->all(); + + if (isset($data['resend_email'])) + { + $this->sendEmailChangeConfirmationEmail($user, $user->new_email_address); + $request->session()->flash('info', trans('auth.change_email_required_message')); + } + + if (isset($data['cancel_change'])) + { + $user->is_email_change_in_progress = false; + $user->new_email_address = null; + $user->save(); + } + + return redirect(route('userSettings')); + } + public function saveSettings(SaveUserSettingsRequest $request) { $data = $request->only(['name', 'email', 'profile_alias', 'enable_profile_page']); $user = $this->getUser(); - if (UserConfig::get('require_email_verification')) + if ( + UserConfig::get('require_email_verification') && + isset($data['email']) && + $data['email'] != $user->email && + !$user->is_email_change_in_progress + ) { // Can't update the e-mail directly until the new e-mail address has been verified. // TODO - send e-mail and handle response, flag e-mail as being "change in-progress" // Send activation e-mail - // Temporarily change the e-mail address so we can send the activation message - $oldEmailAddress = $user->getEmailForPasswordReset(); - $user->email = $data['email']; - - Mail::to($this->getUser())->send(new UserChangeEmailRequired($this->getUser())); + $this->sendEmailChangeConfirmationEmail($user, $data['email']); $request->session()->flash('info', trans('auth.change_email_required_message')); // Flag the user as a change e-mail in progress - $user->new_email_address = $user->email; + $user->new_email_address = $data['email']; $user->is_email_change_in_progress = true; - $user->email = $oldEmailAddress; $user->save(); unset($data['email']); + $request->session()->flash('info', trans('auth.change_email_required_message')); } // Don't allow e-mail address to be changed if a change is in progress @@ -252,4 +299,13 @@ class UserController extends Controller return $results; } + + private function sendEmailChangeConfirmationEmail(User $user, $newEmailAddress) + { + $oldEmailAddress = $user->email; + $user->email = $newEmailAddress; + + Mail::to($user)->send(new UserChangeEmailRequired($user)); + $user->email = $oldEmailAddress; + } } \ No newline at end of file diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index 8ba7e21..b184749 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -21,7 +21,8 @@ return [ 'activation_required_message' => 'An e-mail containing an activation link has been sent to the e-mail address you provided. ' . 'Please click the link in this e-mail to activate your account.', 'change_email_required_message' => 'An e-mail containing an activation link has been sent to the e-mail address you provided. ' . - 'Please click the link in this e-mail to confirm your new e-mail address.', + 'Please click the link in this e-mail to confirm your new e-mail address.', + 'change_email_success_message' => 'Your e-mail address change has been confirmed. You will now need to login with your new e-mail address.', 'change_password_action' => 'Change password', 'change_password_title' => 'Change your password', 'email_password_login' => 'Alternatively, login with your e-mail address and password:', diff --git a/resources/lang/en/gallery.php b/resources/lang/en/gallery.php index b1f1b6b..485683a 100644 --- a/resources/lang/en/gallery.php +++ b/resources/lang/en/gallery.php @@ -79,6 +79,9 @@ return [ 'no_albums_p2' => ':user_name has not created any albums yet.' ], 'user_settings' => [ + 'cancel_email_change' => 'Don\'t change e-mail address', + 'change_email_in_progress' => 'To confirm your new e-mail address, please click on the "confirm" link in the e-mail that was sent to: :new_email_address.', + 'change_email_resend' => 'Re-send confirmation e-mail.', 'change_password' => 'Change password', 'settings_saved' => 'Your settings were updated successfully.', 'title' => 'Change my settings' diff --git a/resources/views/themes/base/email/user_change_email_required.blade.php b/resources/views/themes/base/email/user_change_email_required.blade.php index 62018b6..75fe1e4 100644 --- a/resources/views/themes/base/email/user_change_email_required.blade.php +++ b/resources/views/themes/base/email/user_change_email_required.blade.php @@ -7,7 +7,7 @@ @lang('email.change_email_required_p2') -@component('mail::button', ['url' => route('auth.activate', ['token' => $user->activation_token]), 'color' => 'blue']) +@component('mail::button', ['url' => route('userSettings.confirmEmailChangeState'), 'color' => 'blue']) @lang('forms.confirm_email_action') @endcomponent diff --git a/resources/views/themes/base/gallery/user_settings.blade.php b/resources/views/themes/base/gallery/user_settings.blade.php index 5bfc8b3..461ab04 100644 --- a/resources/views/themes/base/gallery/user_settings.blade.php +++ b/resources/views/themes/base/gallery/user_settings.blade.php @@ -4,7 +4,7 @@ @section('content')
-
+
+ @if ($user->is_email_change_in_progress) + + @endif +
{{ csrf_field() }} diff --git a/routes/web.php b/routes/web.php index 3bc1377..ac76124 100644 --- a/routes/web.php +++ b/routes/web.php @@ -117,6 +117,12 @@ Route::get('label/{labelAlias}', 'Gallery\LabelController@show') Route::get('u/{idOrAlias}', 'Gallery\UserController@show') ->name('viewUser') ->where('idOrAlias', '.*'); +Route::get('me/confirm-email-change', 'Gallery\UserController@confirmEmailChangeState') + ->name('userSettings.confirmEmailChangeState') + ->middleware('auth'); +Route::post('me/reset-email-change', 'Gallery\UserController@resetEmailChangeState') + ->name('userSettings.resetEmailChangeState') + ->middleware('auth'); Route::get('me/settings', 'Gallery\UserController@settings') ->name('userSettings') ->middleware('auth'); From c369ea57031f4879e8223bda8ba86891ae6a09fd Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Wed, 12 Sep 2018 21:24:15 +0100 Subject: [PATCH 7/7] =?UTF-8?q?Added=20validation=20to=20the=20user?= =?UTF-8?q?=E2=80=99s=20profile=20alias=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Requests/SaveUserSettingsRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/SaveUserSettingsRequest.php b/app/Http/Requests/SaveUserSettingsRequest.php index 0c664f2..4797455 100644 --- a/app/Http/Requests/SaveUserSettingsRequest.php +++ b/app/Http/Requests/SaveUserSettingsRequest.php @@ -26,8 +26,8 @@ class SaveUserSettingsRequest extends FormRequest { return [ 'name' => 'required|max:255', - 'email' => 'required|email|max:255|unique:users,email,' . Auth::user()->id - // TODO include user profile alias + 'email' => 'required|email|max:255|unique:users,email,' . Auth::user()->id, + 'profile_alias' => 'sometimes|max:255|unique:users,profile_alias,' . Auth::user()->id ]; } } \ No newline at end of file