Skip to content

Commit

Permalink
Merge pull request #10876 from nanaya/inactive-reset-message
Browse files Browse the repository at this point in the history
Add message on forced password reset
  • Loading branch information
notbakaneko authored Jan 22, 2024
2 parents 02e6f70 + bc17f4f commit 4443882
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/Http/Controllers/SessionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public function store()
if ($forceReactivation->isRequired()) {
$forceReactivation->run();

\Session::flash('password_reset_start', [
'reason' => $forceReactivation->getReason(),
'username' => $username,
]);

return ujs_redirect(route('password-reset'));
}

Expand Down
5 changes: 5 additions & 0 deletions app/Libraries/User/ForceReactivation.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function __construct($user, $request)
}
}

public function getReason(): ?string
{
return $this->reason;
}

public function isRequired()
{
return $this->reason !== null;
Expand Down
6 changes: 5 additions & 1 deletion resources/js/core/user/user-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ export default class UserLogin {
}
};

private readonly loginSuccess = (event: unknown, data: LoginSuccessJson) => {
private readonly loginSuccess = (event: unknown, data: LoginSuccessJson, status: string, xhr: JQuery.jqXHR<unknown>) => {
// check if it's a js callback response and should be run instead
if (xhr.getResponseHeader('content-type') === 'application/javascript') {
return;
}
const callback = this.callback;

if (callback == null) {
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/en/password_reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
'starting' => [
'username' => 'Enter email address or username',

'reason' => [
'inactive_different_country' => "Your account hasn't been used in a long time. To ensure your account security please reset your password.",
],
'support' => [
'_' => 'Need further assistance? Contact us via our :button.',
'button' => 'support system',
Expand Down
15 changes: 14 additions & 1 deletion resources/views/password_reset/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0.
See the LICENCE file in the repository root for full licence text.
--}}
@php
$params = [
'username' => null,
'reason' => null,
...(Session::get('password_reset_start') ?? []),
];
if (isset($params['reason'])) {
$reason = osu_trans("password_reset.starting.reason.{$params['reason']}");
}
@endphp
@extends('master')

@section('content')
Expand All @@ -18,10 +28,13 @@ class="password-reset js-form-error"
method="POST"
>
@csrf
@if (isset($reason))
<p>{{ $reason }}</p>
@endif
<label class="password-reset__input-group">
{{ osu_trans('password_reset.starting.username') }}

<input name="username" class="password-reset__input" autofocus>
<input name="username" class="password-reset__input" value="{{ $params['username'] ?? '' }}" autofocus>

<span class="password-reset__error js-form-error--error"></span>
</label>
Expand Down

0 comments on commit 4443882

Please sign in to comment.