- npm added @japa/api-client, @japa/assert, @types/supertest
Some checks failed
CI Pipeline / japa-tests (push) Failing after 1m13s
Some checks failed
CI Pipeline / japa-tests (push) Failing after 1m13s
- webpack added opions['__VUE_PROD_HYDRATION_MISMATCH_DETAILS__'] = false; - bodyparser config replaced whitelistedMethods with allowedMethods - extended stardust_provider - adapted tests for adonisjs v6
This commit is contained in:
parent
296c8fd46e
commit
bee76f8d5b
23 changed files with 2014 additions and 165 deletions
|
@ -88,13 +88,17 @@ export default class UserController {
|
|||
}
|
||||
|
||||
public async disableTwoFactorAuthentication({ auth, response, session }: HttpContext): Promise<void> {
|
||||
const user = auth.user;
|
||||
const user: User | undefined = auth.user;
|
||||
|
||||
user.twoFactorSecret = null;
|
||||
user.twoFactorRecoveryCodes = null;
|
||||
await user.save();
|
||||
|
||||
session.flash('message', 'Two factor authentication disabled.');
|
||||
if (user) {
|
||||
user.twoFactorSecret = null;
|
||||
user.twoFactorRecoveryCodes = null;
|
||||
await user.save();
|
||||
session.flash('message', 'Two-factor authentication disabled.');
|
||||
} else {
|
||||
session.flash('error', 'User not found.');
|
||||
}
|
||||
|
||||
return response.redirect().back();
|
||||
// return inertia.render('Auth/AccountInfo', {
|
||||
// // status: {
|
||||
|
|
|
@ -38,7 +38,6 @@ import drive from '#services/drive';
|
|||
import { Exception } from '@adonisjs/core/exceptions';
|
||||
import { MultipartFile } from '@adonisjs/core/types/bodyparser';
|
||||
import * as crypto from 'crypto';
|
||||
import app from '@adonisjs/core/services/app';
|
||||
interface Dictionary {
|
||||
[index: string]: string;
|
||||
}
|
||||
|
@ -446,7 +445,7 @@ export default class DatasetController {
|
|||
const mimeType = file.headers['content-type'] || 'application/octet-stream'; // Fallback to a default MIME type
|
||||
const datasetFolder = `files/${dataset.id}`;
|
||||
// const size = file.size;
|
||||
await file.move(app.makePath(datasetFolder), {
|
||||
await file.move(drive.makePath(datasetFolder), {
|
||||
name: fileName,
|
||||
overwrite: true, // overwrite in case of conflict
|
||||
});
|
||||
|
@ -918,10 +917,13 @@ export default class DatasetController {
|
|||
}
|
||||
|
||||
// move to disk:
|
||||
const fileName = `file-${cuid()}.${fileData.extname}`;
|
||||
const datasetFolder = `files/${dataset.id}`;
|
||||
await fileData.moveToDisk(datasetFolder, { name: fileName, overwrite: true }, 'local');
|
||||
// let path = coverImage.filePath;
|
||||
const fileName = `file-${cuid()}.${fileData.extname}`; //'file-ls0jyb8xbzqtrclufu2z2e0c.pdf'
|
||||
const datasetFolder = `files/${dataset.id}`; // 'files/307'
|
||||
// await fileData.moveToDisk(datasetFolder, { name: fileName, overwrite: true }, 'local');
|
||||
await fileData.move(drive.makePath(datasetFolder), {
|
||||
name: fileName,
|
||||
overwrite: true, // overwrite in case of conflict
|
||||
});
|
||||
|
||||
//save to db:
|
||||
const { clientFileName, sortOrder } = this.extractVariableNameAndSortOrder(fileData.clientName);
|
||||
|
|
|
@ -29,7 +29,7 @@ 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; //app.inProduction;
|
||||
protected renderStatusPages = app.inProduction;
|
||||
|
||||
/**
|
||||
* Status pages is a collection of error code range and a callback
|
||||
|
|
|
@ -1,27 +1,47 @@
|
|||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import type { NextFn } from '@adonisjs/core/types/http';
|
||||
|
||||
|
||||
declare global {
|
||||
function myFunction(): boolean;
|
||||
var myVariable: number;
|
||||
|
||||
interface StardustData {
|
||||
pathname?: string;
|
||||
namedRoutes?: Record<string, string>;
|
||||
}
|
||||
var stardust: StardustData;
|
||||
}
|
||||
|
||||
declare global {}
|
||||
export default class StardustMiddleware {
|
||||
async handle(ctx: HttpContext, next: NextFn): Promise<void> {
|
||||
/**
|
||||
* Middleware logic goes here (before the next call)
|
||||
*/
|
||||
// console.log(ctx);
|
||||
const { pathname } = new URL(ctx.request.completeUrl());
|
||||
globalThis.stardust = {
|
||||
...globalThis.stardust,
|
||||
pathname,
|
||||
};
|
||||
|
||||
/**
|
||||
* Call next method in the pipeline and return its output
|
||||
*/
|
||||
const output = await next();
|
||||
return output;
|
||||
// Check if the request is an API request
|
||||
if (!ctx.request.url().startsWith('/api')) {
|
||||
// Middleware logic for non-API requests
|
||||
const { pathname } = new URL(ctx.request.completeUrl()); // '/', '/app/login'
|
||||
globalThis.myFunction = () => {
|
||||
return true;
|
||||
};
|
||||
globalThis.myVariable = 1;
|
||||
|
||||
globalThis.stardust = {
|
||||
...globalThis.stardust,
|
||||
pathname,
|
||||
};
|
||||
|
||||
/**
|
||||
* Call next method in the pipeline and return its output
|
||||
*/
|
||||
await next();
|
||||
} else {
|
||||
// Skip middleware for API requests
|
||||
await next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
||||
// export default class StardustMiddleware {
|
||||
// handle({ request }: HttpContextContract, next: () => Promise<void>): Promise<void>;
|
||||
// }
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue