mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-19 03:16:49 +02:00
Adapt back-end to the new front-end auth management
This commit is contained in:
parent
48bea5721f
commit
0435cecd53
@ -8,6 +8,7 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
||||
* @property mixed $id
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property \Illuminate\Support\Collection<array-key, mixed> $preferences
|
||||
* @property string $is_admin
|
||||
*/
|
||||
class UserResource extends JsonResource
|
||||
@ -21,10 +22,11 @@ class UserResource extends JsonResource
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'is_admin' => $this->is_admin,
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'preferences' => $this->preferences,
|
||||
'is_admin' => $this->is_admin,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,7 @@ class LoginController extends Controller
|
||||
'message' => 'authenticated',
|
||||
'name' => $name,
|
||||
'preferences' => $this->guard()->user()->preferences,
|
||||
'is_admin' => $this->guard()->user()->is_admin,
|
||||
], Response::HTTP_OK);
|
||||
}
|
||||
|
||||
|
@ -18,15 +18,15 @@ class SinglePageController extends Controller
|
||||
{
|
||||
event(new ScanForNewReleaseCalled());
|
||||
|
||||
$settings = Settings::all()->toJson();
|
||||
$proxyAuth = config('auth.defaults.guard') === 'reverse-proxy-guard' ? true : false;
|
||||
$proxyLogoutUrl = config('2fauth.config.proxyLogoutUrl') ? config('2fauth.config.proxyLogoutUrl') : false;
|
||||
$subdir = config('2fauth.config.appSubdirectory') ? '/' . config('2fauth.config.appSubdirectory') : '';
|
||||
$userPreferences = Auth::user()->preferences ?? collect(config('2fauth.preferences')); /** @phpstan-ignore-line */
|
||||
$isDemoApp = config('2fauth.config.isDemoApp') ? 'true' : 'false';
|
||||
$isTestingApp = config('2fauth.config.isTestingApp') ? 'true' : 'false';
|
||||
$lang = App::getLocale();
|
||||
$locales = collect(config('2fauth.locales'))->toJson(); /** @phpstan-ignore-line */
|
||||
$settings = Settings::all()->toJson();
|
||||
$proxyAuth = config('auth.defaults.guard') === 'reverse-proxy-guard' ? true : false;
|
||||
$proxyLogoutUrl = config('2fauth.config.proxyLogoutUrl') ? config('2fauth.config.proxyLogoutUrl') : false;
|
||||
$subdir = config('2fauth.config.appSubdirectory') ? '/' . config('2fauth.config.appSubdirectory') : '';
|
||||
$defaultPreferences = collect(config('2fauth.preferences')); /** @phpstan-ignore-line */
|
||||
$isDemoApp = config('2fauth.config.isDemoApp') ? 'true' : 'false';
|
||||
$isTestingApp = config('2fauth.config.isTestingApp') ? 'true' : 'false';
|
||||
$lang = App::getLocale();
|
||||
$locales = collect(config('2fauth.locales'))->toJson(); /** @phpstan-ignore-line */
|
||||
|
||||
// if (Auth::user()->preferences)
|
||||
|
||||
@ -37,12 +37,12 @@ class SinglePageController extends Controller
|
||||
'proxyLogoutUrl' => $proxyLogoutUrl,
|
||||
'subdirectory' => $subdir,
|
||||
])->toJson(),
|
||||
'userPreferences' => $userPreferences,
|
||||
'subdirectory' => $subdir,
|
||||
'isDemoApp' => $isDemoApp,
|
||||
'isTestingApp' => $isTestingApp,
|
||||
'lang' => $lang,
|
||||
'locales' => $locales,
|
||||
'defaultPreferences' => $defaultPreferences,
|
||||
'subdirectory' => $subdir,
|
||||
'isDemoApp' => $isDemoApp,
|
||||
'isTestingApp' => $isTestingApp,
|
||||
'lang' => $lang,
|
||||
'locales' => $locales,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ return [
|
||||
'autolock_triggered' => 'Auto lock triggered',
|
||||
'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.',
|
||||
'already_authenticated' => 'Already authenticated',
|
||||
'already_authenticated' => 'Already authenticated, please log out first',
|
||||
'authentication' => 'Authentication',
|
||||
'maybe_later' => 'Maybe later',
|
||||
'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>
|
||||
<html data-theme="{{ $userPreferences['theme'] }}" lang="{{ $lang }}">
|
||||
<html data-theme="{{ $defaultPreferences['theme'] }}" lang="{{ $lang }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
@ -25,7 +25,7 @@
|
||||
<script type="text/javascript">
|
||||
var appSettings = {!! $appSettings !!};
|
||||
var appConfig = {!! $appConfig !!};
|
||||
var userPreferences = {!! $userPreferences->toJson() !!};
|
||||
var defaultPreferences = {!! $defaultPreferences->toJson() !!};
|
||||
var appVersion = '{{ config("2fauth.version") }}';
|
||||
var isDemoApp = {!! $isDemoApp !!};
|
||||
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)
|
||||
* 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('webauthn/login', [WebAuthnLoginController::class, 'login'])->name('webauthn.login');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user