custom authentication docs are confusing, incomplete and/or incorrect
See original GitHub issueI am trying to follow the guide here: https://nestjs-admin.com/docs/custom-authentication, for providing custom authentication for the nestjs-admin
app. There are a couple of issues with the docs and/or the code that I don’t understand.
FIrst, there is no static method create()
on the AdminAuthModuleFactory
class. Rather, it’s createAdminAuthModule()
, but that method does not allow provisioning a credentialProvider
property through the factory as per the docs. The type accepted by that call only allows adminCoreModule
, not an instance of AdminAuthModuleConfig
.
Second, assuming I could get past the first issue, the CredentialValidatorProvider
type does not appear to be exported from nestjs-amin
, at least not from the top-level index
. So just creating the validator doesn’t work either. Also, the AdminAuthModuleConfig
interface is not exported at all, so I’m not sure how that type gets exposed either.
Short of tweaking the credential provider a little I haven’t strayed very far from the docs at all. Is there something I’m missing here? Using version 0.3.0.
Here is the error output:
TS2345: Argument of type '{ adminCoreModule: { module: typeof AdminCoreModuleFactory; controllers: (typeof DefaultAdminController)[]; providers: (typeof DefaultAdminNunjucksEnvironment | typeof DefaultAdminSite | { ...; } | { ...; } | { ...; })[]; exports: (typeof DefaultAdminNunjucksEnvironment | ... 3 more ... | { ...; })[]; }; credentialP...' is not assignable to parameter of type 'AdminAuthModuleConfig'.
Object literal may only specify known properties, and 'credentialProvider' does not exist in type 'AdminAuthModuleConfig'.
ERROR in .../src/backoffice/credentialValidator.ts
./src/backoffice/credentialValidator.ts
ERROR in .../src/backoffice/credentialValidator.ts(2,10)
TS2305: Module '"../../../../../../../Users/lerickson/dev/hospitality/hospitality-api/node_modules/nestjs-admin/dist/src"' has no exported member 'CredentialValidatorProvider'.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Thank you @ishpartko for your PR! The docs are indeed somehow outdated, I do realise this is confusing and annoying. I struggle to find the time to maintain this library as well as it deserves, sadly. Hopefully it’ll get better!
@lerickson-control4 good news for us. I have found the sample with using the Validator of admin login. See here: https://github.com/Theodo-UK/nestjs-admin/blob/master/exampleApp/src/user/userCredentialValidator.ts
We mustn’t use the CredentialValidatorProvider in the new way to do this.
This is solution.