- added own provider for drive methods

- renamed middleware Role and Can to role_middleware and can_middleware
- added some typing for inertia vue3 components
- npm updates
This commit is contained in:
Kaimbacher 2024-04-23 19:36:45 +02:00
parent cb51a4136f
commit 296c8fd46e
67 changed files with 2515 additions and 1913 deletions

View file

@ -29,28 +29,38 @@ export default class HttpExceptionHandler extends ExceptionHandler {
* codes. You might want to enable them in production only, but feel
* free to enable them in development as well.
*/
protected renderStatusPages = true;
// protected statusPages = {
// '401,403': 'errors/unauthorized',
// '404': 'errors/not-found',
// '500..599': 'errors/server-error',
// };
protected renderStatusPages = true; //app.inProduction;
/**
* Status pages is a collection of error code range and a callback
* to return the HTML contents to send as a response.
*/
// protected statusPages: Record<StatusPageRange, StatusPageRenderer> = {
// '401..403': (error, { view }) => {
// return view.render('./errors/unauthorized', { error });
// },
// '404': (error, { view }) => {
// return view.render('./errors/not-found', { error });
// },
// '500..599': (error, { view }) => {
// return view.render('./errors/server-error', { error });
// },
// };
protected statusPages: Record<StatusPageRange, StatusPageRenderer> = {
'401..403': (error, { view }) => {
return view.render('./errors/unauthorized', { error });
'404': (error, { inertia }) => {
return inertia.render('Errors/ServerError', {
error: error.message,
code: error.status,
});
},
'404': (error, { view }) => {
return view.render('./errors/not-found', { error });
},
'500..599': (error, { view }) => {
return view.render('./errors/server-error', { error });
'401..403': async (error, { inertia }) => {
// session.flash('errors', error.message);
return inertia.render('Errors/ServerError', {
error: error.message,
code: error.status,
});
},
'500..599': (error, { inertia }) => inertia.render('Errors/ServerError', { error: error.message, code: error.status }),
};
// constructor() {
@ -58,7 +68,7 @@ export default class HttpExceptionHandler extends ExceptionHandler {
// }
public async handle(error: any, ctx: HttpContext) {
const { response, request, session } = ctx;
// const { response, request, session, inertia } = ctx;
/**
* Handle failed authentication attempt
@ -75,17 +85,26 @@ export default class HttpExceptionHandler extends ExceptionHandler {
// https://github.com/inertiajs/inertia-laravel/issues/56
// let test = response.getStatus(); //200
// let header = request.header('X-Inertia'); // true
if (request.header('X-Inertia') && [500, 503, 404, 403, 401, 200].includes(response.getStatus())) {
// session.flash('errors', error.messages.errors);
session.flash('errors', error.messages);
return response.redirect().back();
// return inertia.render('Error', {
// status: response.getStatus(),
// message: error.message,
// });
// ->toResponse($request)
// ->setStatusCode($response->status());
}
// if (request.header('X-Inertia') && [500, 503, 404, 403, 401, 200].includes(response.getStatus())) {
// // session.flash('errors', error.messages.errors);
// session.flash('errors', error.messages);
// return response.redirect().back();
// // return inertia.render('errors/server_error', {
// // return inertia.render('errors/server_error', {
// // // status: response.getStatus(),
// // error: error,
// // });
// // ->toResponse($request)
// // ->setStatusCode($response->status());
// }
// Dynamically change the error templates based on the absence of X-Inertia header
// if (!ctx.request.header('X-Inertia')) {
// this.statusPages = {
// '401..403': (error, { view }) => view.render('./errors/unauthorized', { error }),
// '404': (error, { view }) => view.render('./errors/not-found', { error }),
// '500..599': (error, { view }) => view.render('./errors/server-error', { error }),
// };
// }
/**
* Forward rest of the exceptions to the parent class