Skip to content

Commit

Permalink
Fix for #4
Browse files Browse the repository at this point in the history
Replace language strings, add styles and improve the 2fa-switch order.
  • Loading branch information
roelreijneveld committed Dec 27, 2020
1 parent 30ee645 commit eba37bf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 35 deletions.
29 changes: 24 additions & 5 deletions stubs/resources/views/profile/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
</div>
@endif

@if(session('status') == 'two-factor-authentication-enabled')
{{-- Show SVG QR Code, After Enabling 2FA --}}
<div class="alert alert-success" id="enable2fa">
<p class="mb-2">
{{ __('Two factor authentication is now enabled. Scan the following QR code using your phone\'s authenticator application.') }}
</p>
<div>{!! auth()->user()->twoFactorQrCodeSvg() !!}</div>
</div>
<style>
#enable2fa svg {
border: 10px solid #fff;
}
</style>
@endif

<div class="row mb-3">
<div class="col-2 text-center m-auto">
<span
Expand Down Expand Up @@ -78,6 +93,8 @@ class="avatar avatar-xl"></span>

<hr>

<h2>{{ __('Active Sessions') }}</h2>

<div class="table-responsive">
<table class="table table-vcenter datatable">
<thead>
Expand Down Expand Up @@ -122,20 +139,22 @@ class="avatar avatar-xl"></span>
@csrf
@method('PUT')

<h2>{{ __('Change Password') }}</h2>

<div class="mb-3">
<label class="form-label">{{ __('dashboard.profile.update.currentpassword') }}</label>
<label class="form-label">{{ __('Current Password') }}</label>
<input type="password" name="current_password" class="form-control" required
autocomplete="current-password" />
</div>

<div class="mb-3">
<label class="form-label">{{ __('dashboard.profile.update.newpassword') }}</label>
<label class="form-label">{{ __('New Password') }}</label>
<input type="password" name="password" class="form-control" required
autocomplete="new-password" />
</div>

<div class="mb-3">
<label>{{ __('dashboard.profile.update.currentpassword') }}</label>
<label>{{ __('Confirm New Password') }}</label>
<input type="password" name="password_confirmation" class="form-control" required
autocomplete="new-password" />
</div>
Expand All @@ -147,9 +166,9 @@ class="avatar avatar-xl"></span>
</div>
</form>

<hr>

@if (Laravel\Fortify\Features::enabled(Laravel\Fortify\Features::twoFactorAuthentication()))
<hr>
<h2>{{ __('Two Factor Authentication') }}</h2>
@include('profile.two-factor-authentication-form')
@endif
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,38 @@
<form method="POST" action="{{ url('user/two-factor-authentication') }}">
@csrf

<button type="submit">
<button type="submit" class="btn btn-primary mb-3">
{{ __('Enable Two-Factor') }}
</button>
</form>
@else
{{-- Disable 2FA --}}
<form method="POST" action="{{ url('user/two-factor-authentication') }}">
@csrf
@method('DELETE')

<button type="submit">
{{ __('Disable Two-Factor') }}
</button>
</form>

@if(session('status') == 'two-factor-authentication-enabled')
{{-- Show SVG QR Code, After Enabling 2FA --}}
<div>
{{ __('Two factor authentication is now enabled. Scan the following QR code using your phone\'s authenticator application.') }}
</div>

<div>
{!! auth()->user()->twoFactorQrCodeSvg() !!}
</div>
@endif

{{-- Show 2FA Recovery Codes --}}
<div>
<p class="mb-2">
{{ __('Store these recovery codes in a secure password manager. They can be used to recover access to your account if your two factor authentication device is lost.') }}
</div>
</p>

<div>
<ul class="list-group mb-3">
@foreach (json_decode(decrypt(auth()->user()->two_factor_recovery_codes), true) as $code)
<div>{{ $code }}</div>
<li class="list-group-item">{{ $code }}</li>
@endforeach
</div>
</ul>

{{-- Regenerate 2FA Recovery Codes --}}
<form method="POST" action="{{ url('user/two-factor-recovery-codes') }}">
<form method="POST" action="{{ url('user/two-factor-recovery-codes') }}" id="regenerateCodeForm">
@csrf
</form>

{{-- Disable 2FA --}}
<form method="POST" action="{{ url('user/two-factor-authentication') }}">
@csrf
@method('DELETE')

<button type="submit">
<button class="btn btn-primary" onclick='event.preventDefault(); document.getElementById("regenerateCodeForm").submit();'>
{{ __('Regenerate Recovery Codes') }}
</button>

<button type="submit" class="btn btn-danger">
{{ __('Disable Two-Factor') }}
</button>
</form>
@endif
<hr>

0 comments on commit eba37bf

Please sign in to comment.