nest-authz
nest-authz copied to clipboard
What is the `name` field in configuration used for?
In the documentation there is the following code:
import { TypeOrmModule } from '@nestjs/typeorm';
@Module({
imports: [
AuthZModule.register({
model: 'model.conf',
policy: TypeORMAdapter.newAdapter({
name: 'casbin',
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: 'password',
database: 'nestdb'
}),
usernameFromContext: (ctx) => {
const request = ctx.switchToHttp().getRequest();
return request.user && request.user.username;
}
}),
],
})
What does the name field do in TypeORMAdapter?
@Gabriel-403 @Zxilly @nodece
@dzcpy The name field is the TypeORM instance name.
@nodece 谢谢解答,不过这个 field 有实际的用处吗?
@dzcpy plz use English
@dzcpy it's useless and has been removed: https://github.com/node-casbin/nest-authz/commit/bd99591e824fd8c7b0b2c40172361a21fa18aeef
Refer to a better example here: https://github.com/node-casbin/typeorm-adapter#simple-example