nest-authz icon indicating copy to clipboard operation
nest-authz copied to clipboard

What is the `name` field in configuration used for?

Open yf-hk opened this issue 4 years ago • 4 comments

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?

yf-hk avatar Sep 25 '21 02:09 yf-hk

@Gabriel-403 @Zxilly @nodece

hsluoyz avatar Sep 25 '21 05:09 hsluoyz

@dzcpy The name field is the TypeORM instance name.

nodece avatar Sep 25 '21 11:09 nodece

@nodece 谢谢解答,不过这个 field 有实际的用处吗?

yf-hk avatar Sep 25 '21 16:09 yf-hk

@dzcpy plz use English

hsluoyz avatar Sep 25 '21 17:09 hsluoyz

@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

hsluoyz avatar Jul 18 '23 15:07 hsluoyz