tethys.backend/start/inertia.ts
Arno Kaimbacher f828ca4491
All checks were successful
CI Pipeline / japa-tests (push) Successful in 1m2s
- added 2fa authentication during login. see resources/js/Pages/Auth/login.vue
- added validate() method inside app/Srvices/TwoFactorProvider.ts
- added twoFactorChallenge() method inside app/Controllers/Http/Auth/AuthController.ts for logging in via 2fa-code
2024-02-16 15:32:47 +01:00

48 lines
1.3 KiB
TypeScript

/*
|--------------------------------------------------------------------------
| Inertia Preloaded File
|--------------------------------------------------------------------------
|
| Any code written inside this file will be executed during the application
| boot.
|
*/
import Inertia from '@ioc:EidelLev/Inertia';
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
Inertia.share({
errors: (ctx) => {
return ctx.session.flashMessages.get('errors');
},
user_id: (ctx) => {
return ctx.session.flashMessages.get('user_id');
},
flash: (ctx) => {
return {
message: ctx.session.flashMessages.get('message'),
warning: ctx.session.flashMessages.get('warning'),
};
},
// params: ({ params }) => params,
authUser: async ({ auth }: HttpContextContract) => {
if (auth.user) {
await auth.user.load('roles');
return auth.user;
// {
// 'id': auth.user.id,
// 'login': auth.user.login,
// };
} else {
return null;
}
},
}).version(() => Inertia.manifestFile('public/assets/manifest.json'));
// 'flash' => [
// 'message' => fn () => $request->session()->get('message'),
// ],