mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-09 05:54:34 +02:00
Adapt back-end to the new front-end auth management
This commit is contained in:
@ -8,6 +8,7 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
|||||||
* @property mixed $id
|
* @property mixed $id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string $email
|
* @property string $email
|
||||||
|
* @property \Illuminate\Support\Collection<array-key, mixed> $preferences
|
||||||
* @property string $is_admin
|
* @property string $is_admin
|
||||||
*/
|
*/
|
||||||
class UserResource extends JsonResource
|
class UserResource extends JsonResource
|
||||||
@ -24,6 +25,7 @@ class UserResource extends JsonResource
|
|||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'email' => $this->email,
|
'email' => $this->email,
|
||||||
|
'preferences' => $this->preferences,
|
||||||
'is_admin' => $this->is_admin,
|
'is_admin' => $this->is_admin,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,7 @@ class LoginController extends Controller
|
|||||||
'message' => 'authenticated',
|
'message' => 'authenticated',
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'preferences' => $this->guard()->user()->preferences,
|
'preferences' => $this->guard()->user()->preferences,
|
||||||
|
'is_admin' => $this->guard()->user()->is_admin,
|
||||||
], Response::HTTP_OK);
|
], Response::HTTP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class SinglePageController extends Controller
|
|||||||
$proxyAuth = config('auth.defaults.guard') === 'reverse-proxy-guard' ? true : false;
|
$proxyAuth = config('auth.defaults.guard') === 'reverse-proxy-guard' ? true : false;
|
||||||
$proxyLogoutUrl = config('2fauth.config.proxyLogoutUrl') ? config('2fauth.config.proxyLogoutUrl') : false;
|
$proxyLogoutUrl = config('2fauth.config.proxyLogoutUrl') ? config('2fauth.config.proxyLogoutUrl') : false;
|
||||||
$subdir = config('2fauth.config.appSubdirectory') ? '/' . config('2fauth.config.appSubdirectory') : '';
|
$subdir = config('2fauth.config.appSubdirectory') ? '/' . config('2fauth.config.appSubdirectory') : '';
|
||||||
$userPreferences = Auth::user()->preferences ?? collect(config('2fauth.preferences')); /** @phpstan-ignore-line */
|
$defaultPreferences = collect(config('2fauth.preferences')); /** @phpstan-ignore-line */
|
||||||
$isDemoApp = config('2fauth.config.isDemoApp') ? 'true' : 'false';
|
$isDemoApp = config('2fauth.config.isDemoApp') ? 'true' : 'false';
|
||||||
$isTestingApp = config('2fauth.config.isTestingApp') ? 'true' : 'false';
|
$isTestingApp = config('2fauth.config.isTestingApp') ? 'true' : 'false';
|
||||||
$lang = App::getLocale();
|
$lang = App::getLocale();
|
||||||
@ -37,7 +37,7 @@ class SinglePageController extends Controller
|
|||||||
'proxyLogoutUrl' => $proxyLogoutUrl,
|
'proxyLogoutUrl' => $proxyLogoutUrl,
|
||||||
'subdirectory' => $subdir,
|
'subdirectory' => $subdir,
|
||||||
])->toJson(),
|
])->toJson(),
|
||||||
'userPreferences' => $userPreferences,
|
'defaultPreferences' => $defaultPreferences,
|
||||||
'subdirectory' => $subdir,
|
'subdirectory' => $subdir,
|
||||||
'isDemoApp' => $isDemoApp,
|
'isDemoApp' => $isDemoApp,
|
||||||
'isTestingApp' => $isTestingApp,
|
'isTestingApp' => $isTestingApp,
|
||||||
|
@ -29,7 +29,7 @@ return [
|
|||||||
'autolock_triggered' => 'Auto lock triggered',
|
'autolock_triggered' => 'Auto lock triggered',
|
||||||
'autolock_triggered_punchline' => 'The event watched by the Auto Lock feature has fired. You\'ve been automatically disconnected.',
|
'autolock_triggered_punchline' => 'The event watched by the Auto Lock feature has fired. You\'ve been automatically disconnected.',
|
||||||
'change_autolock_in_settings' => 'You can change the behavior of the Autolock feature in Settings > Options tab.',
|
'change_autolock_in_settings' => 'You can change the behavior of the Autolock feature in Settings > Options tab.',
|
||||||
'already_authenticated' => 'Already authenticated',
|
'already_authenticated' => 'Already authenticated, please log out first',
|
||||||
'authentication' => 'Authentication',
|
'authentication' => 'Authentication',
|
||||||
'maybe_later' => 'Maybe later',
|
'maybe_later' => 'Maybe later',
|
||||||
'user_account_controlled_by_proxy' => 'User account made available by an authentication proxy.<br />Manage the account at proxy level.',
|
'user_account_controlled_by_proxy' => 'User account made available by an authentication proxy.<br />Manage the account at proxy level.',
|
||||||
|
4
resources/views/landing_v3.blade.php
vendored
4
resources/views/landing_v3.blade.php
vendored
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html data-theme="{{ $userPreferences['theme'] }}" lang="{{ $lang }}">
|
<html data-theme="{{ $defaultPreferences['theme'] }}" lang="{{ $lang }}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var appSettings = {!! $appSettings !!};
|
var appSettings = {!! $appSettings !!};
|
||||||
var appConfig = {!! $appConfig !!};
|
var appConfig = {!! $appConfig !!};
|
||||||
var userPreferences = {!! $userPreferences->toJson() !!};
|
var defaultPreferences = {!! $defaultPreferences->toJson() !!};
|
||||||
var appVersion = '{{ config("2fauth.version") }}';
|
var appVersion = '{{ config("2fauth.version") }}';
|
||||||
var isDemoApp = {!! $isDemoApp !!};
|
var isDemoApp = {!! $isDemoApp !!};
|
||||||
var isTestingApp = {!! $isTestingApp !!};
|
var isTestingApp = {!! $isTestingApp !!};
|
||||||
|
@ -44,7 +44,7 @@ Route::group(['middleware' => ['rejectIfDemoMode', 'throttle:10,1']], function (
|
|||||||
* Routes that only work for unauthenticated user (return an error otherwise)
|
* Routes that only work for unauthenticated user (return an error otherwise)
|
||||||
* that can be requested max 10 times per minute by the same IP
|
* that can be requested max 10 times per minute by the same IP
|
||||||
*/
|
*/
|
||||||
Route::group(['middleware' => ['SkipIfAuthenticated', 'throttle:10,1']], function () {
|
Route::group(['middleware' => ['guest', 'throttle:10,1']], function () {
|
||||||
Route::post('user/login', [LoginController::class, 'login'])->name('user.login');
|
Route::post('user/login', [LoginController::class, 'login'])->name('user.login');
|
||||||
Route::post('webauthn/login', [WebAuthnLoginController::class, 'login'])->name('webauthn.login');
|
Route::post('webauthn/login', [WebAuthnLoginController::class, 'login'])->name('webauthn.login');
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user