Skip to content

Commit

Permalink
revert some changes in EditProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy132 committed Jun 7, 2024
1 parent f43fb98 commit 70fc843
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/Filament/Resources/UserResource/Pages/EditProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
use Illuminate\Support\HtmlString;
use Illuminate\Validation\Rules\Password;

/**
* @method User getUser()
*/
class EditProfile extends \Filament\Pages\Auth\EditProfile
{
protected function getForms(): array
Expand Down Expand Up @@ -101,18 +104,15 @@ protected function getForms(): array
->icon('tabler-shield-lock')
->schema(function () {

/** @var User */
$user = auth()->user();

if (auth()->user()->use_totp) {
if ($this->getUser()->use_totp) {
return [
Placeholder::make('2fa-already-enabled')
->label('Two Factor Authentication is currently enabled!'),
Textarea::make('backup-tokens')
->hidden(fn () => !cache()->get("users.{$user->id}.2fa.tokens"))
->hidden(fn () => !cache()->get("users.{$this->getUser()->id}.2fa.tokens"))
->rows(10)
->readOnly()
->formatStateUsing(fn () => cache()->get("users.{$user->id}.2fa.tokens"))
->formatStateUsing(fn () => cache()->get("users.{$this->getUser()->id}.2fa.tokens"))
->helperText('These will not be shown again!')
->label('Backup Tokens:'),
TextInput::make('2fa-disable-code')
Expand All @@ -124,8 +124,8 @@ protected function getForms(): array
$setupService = app(TwoFactorSetupService::class);

['image_url_data' => $url, 'secret' => $secret] = cache()->remember(
"users.{$user->id}.2fa.state",
now()->addMinutes(5), fn () => $setupService->handle(auth()->user())
"users.{$this->getUser()->id}.2fa.state",
now()->addMinutes(5), fn () => $setupService->handle($this->getUser())
);

$options = new QROptions([
Expand Down Expand Up @@ -265,7 +265,7 @@ protected function getForms(): array
]),
])
->operation('edit')
->model(auth()->user())
->model($this->getUser())
->statePath('data')
->inlineLabel(!static::isSimple()),
),
Expand Down

0 comments on commit 70fc843

Please sign in to comment.