auth db login workflow

This commit is contained in:
Jan Prochazka
2024-08-06 12:45:28 +02:00
parent 5d6d827044
commit 196c0b8a3e
7 changed files with 70 additions and 12 deletions

View File

@@ -412,6 +412,22 @@ module.exports = {
}
},
dbloginAuthToken_meta: true,
async dbloginAuthToken({ code, conid, redirectUri }) {
try {
const connection = await this.getCore({ conid });
const driver = requireEngineDriver(connection);
const accessToken = await driver.getAuthTokenFromCode(connection, { code, redirectUri });
const volatile = await this.saveVolatile({ conid, accessToken });
const authProvider = getAuthProvider();
const resp = await authProvider.login(null, null, { conid: volatile._id });
return resp;
} catch (err) {
logger.error({ err }, 'Error getting DB token');
return { error: err.message };
}
},
dbloginAuth_meta: true,
async dbloginAuth({ conid, user, password }) {
if (user || password) {