Closed swapnilnandgave closed 3 years ago
Default connection is working as expected but I want to switch db connection before auth.attempt
Can somebody help me with this? It is bit urgent.I have tried below but nothing works.
First tried this
User.connection = connectionName
- doesn't work
Then
ctx.auth.config.provider.connection = connectionName
- doesn't work
Then
user.useConnection(connectionName)
- doesn't work
Then in User.ts
static get connection () { return 'mssql4'; }
- doesn't work
Even I have tried by adding new guard and tried but it is taking default env connection instead of mentioned connection defined in guard list
api4: {
driver: 'oat',
tokenProvider: {
type: 'api',
driver: 'database',
table: 'api_tokens',
foreignKey: 'user_id',
},
provider: {
driver: 'database',
identifierKey: 'id',
uids: ['email'],
usersTable: 'users',
connection: 'mssql4'
},
},
In interface ProvidersList
dbuser: {
implementation: DatabaseProviderContract<DatabaseProviderRow>,
config: DatabaseProviderConfig,
},
In interface GuardsList
api4: { implementation: OATGuardContract<'dbuser', 'api'>, config: OATGuardConfig<'dbuser'>, },
Nothing works for me. Anything missing over here
Issue doesn't adhere to the guidelines of creating a proper issue.
If you are not submitting a bug and neither a feature request, then please use the discussion threads
In any case, issues which are not descriptive enough will be closed. Please respect our time.
How do i set db connection name while auth.attempt?
we have changing database connection on the fly as per request using Database.connection but while trying do auth.attempt then it uses default connection which is set in env
Is there any way to set connection before auth.attempt?