diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php index 6916409..56112b8 100644 --- a/app/Http/Controllers/Auth/PasswordController.php +++ b/app/Http/Controllers/Auth/PasswordController.php @@ -15,6 +15,20 @@ class PasswordController extends Controller */ public function update(Request $request): RedirectResponse { + // If user logged in with Discord and has not yet a password, allow to set password + if ($request->user()->discord_id && is_null($request->user()->password)) + { + $validated = $request->validateWithBag('updatePassword', [ + 'password' => ['required', Password::defaults(), 'confirmed'], + ]); + + $request->user()->update([ + 'password' => Hash::make($validated['password']), + ]); + + return back()->with('status', 'password-updated'); + } + $validated = $request->validateWithBag('updatePassword', [ 'current_password' => ['required', 'current_password'], 'password' => ['required', Password::defaults(), 'confirmed'], diff --git a/resources/views/profile/partials/update-password-form.blade.php b/resources/views/profile/partials/update-password-form.blade.php index acd200d..5172eff 100644 --- a/resources/views/profile/partials/update-password-form.blade.php +++ b/resources/views/profile/partials/update-password-form.blade.php @@ -7,17 +7,33 @@

{{ __('Ensure your account is using a long, random password to stay secure.') }}

+ + @if ($user->discord_id && is_null($user->password)) +
+

+ {{ __('You currently don\'t have a password set, as you use Discord authentication. You can set a password to be able to login with email & password.') }} +

+
+ @elseif ($user->discord_id && !is_null($user->password)) +
+

+ {{ __('Both Discord and email login are enabled.') }} +

+
+ @endif
@csrf @method('put') + @if (!(is_null($user->password) && $user->discord_id))
+ @endif
diff --git a/resources/views/profile/partials/update-profile-information-form.blade.php b/resources/views/profile/partials/update-profile-information-form.blade.php index d3bd30a..3af3af0 100644 --- a/resources/views/profile/partials/update-profile-information-form.blade.php +++ b/resources/views/profile/partials/update-profile-information-form.blade.php @@ -4,9 +4,19 @@ {{ __('Profile Information') }} -

- {{ __("Update your account's profile information and email address.") }} -

+ @if ($user->discord_id) +
+

+ {{ __('Changing your name or email will not affect Discord authentication, as your Discord ID has been stored.') }} +

+
+ @else +
+

+ {{ __('If you want to use Discord authentication, ensure the email addresses match for initial login. After login with Discord, email can be changed.') }} +

+
+ @endif @@ -19,13 +29,13 @@
- +
- + @if ($user instanceof \Illuminate\Contracts\Auth\MustVerifyEmail && ! $user->hasVerifiedEmail()) @@ -47,7 +57,7 @@ @endif
- {{--
+
{{ __('Save') }} @if (session('status') === 'profile-updated') @@ -59,6 +69,6 @@ class="text-sm text-gray-600 dark:text-gray-400" >{{ __('Saved.') }}

@endif -
--}} +
diff --git a/resources/views/profile/settings.blade.php b/resources/views/profile/settings.blade.php index cac2e65..1b5d38e 100644 --- a/resources/views/profile/settings.blade.php +++ b/resources/views/profile/settings.blade.php @@ -8,13 +8,16 @@
@include('user.partials.background') -
+
@include('profile.partials.sidebar') -
+
@include('profile.partials.update-profile-information-form')
+
+ @include('profile.partials.update-password-form') +
@include('profile.partials.update-blacklist-form')