mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +00:00
fix: relations between tables
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import PATHS from '#constants/paths';
|
||||
import type { Authenticators } from '@adonisjs/auth/types';
|
||||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import type { NextFn } from '@adonisjs/core/types/http';
|
||||
import type { Authenticators } from '@adonisjs/auth/types';
|
||||
|
||||
/**
|
||||
* Auth middleware is used authenticate HTTP requests and deny
|
||||
@@ -10,7 +11,7 @@ export default class AuthMiddleware {
|
||||
/**
|
||||
* The URL to redirect to, when authentication fails
|
||||
*/
|
||||
redirectTo = '/login';
|
||||
redirectTo = PATHS.AUTH.LOGIN;
|
||||
|
||||
async handle(
|
||||
ctx: HttpContext,
|
||||
@@ -19,7 +20,9 @@ export default class AuthMiddleware {
|
||||
guards?: (keyof Authenticators)[];
|
||||
} = {}
|
||||
) {
|
||||
await ctx.auth.authenticateUsing(options.guards, { loginRoute: this.redirectTo });
|
||||
await ctx.auth.authenticateUsing(options.guards, {
|
||||
loginRoute: this.redirectTo,
|
||||
});
|
||||
return next();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Collection from '#models/collection';
|
||||
import Link from '#models/link';
|
||||
import type { GoogleToken } from '@adonisjs/ally/types';
|
||||
import { column, manyToMany } from '@adonisjs/lucid/orm';
|
||||
import type { ManyToMany } from '@adonisjs/lucid/types/relations';
|
||||
@@ -30,4 +31,9 @@ export default class User extends AppBaseModel {
|
||||
relatedKey: 'authorId',
|
||||
})
|
||||
declare collections: ManyToMany<typeof Collection>;
|
||||
|
||||
@manyToMany(() => Link, {
|
||||
relatedKey: 'authorId',
|
||||
})
|
||||
declare links: ManyToMany<typeof Link>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user