Fix for oauth user db update
This commit is contained in:
parent
2ea4a9d225
commit
79f54d5873
|
@ -130,18 +130,22 @@ async function refreshOAuthToken(refreshToken, configType, configId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateUserOAuth(userId, oAuthConfig) {
|
async function updateUserOAuth(userId, oAuthConfig) {
|
||||||
const details = { ...oAuthConfig }
|
const details = {
|
||||||
|
accessToken: oAuthConfig.accessToken,
|
||||||
|
refreshToken: oAuthConfig.refreshToken,
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const db = getGlobalDB()
|
const db = getGlobalDB()
|
||||||
const dbUser = db.get(userId)
|
const dbUser = await db.get(userId)
|
||||||
|
|
||||||
//Do not overwrite the refresh token if a valid one is not provided.
|
//Do not overwrite the refresh token if a valid one is not provided.
|
||||||
if (typeof details.refreshToken !== "string") {
|
if (typeof details.refreshToken !== "string") {
|
||||||
delete details.refreshToken
|
delete details.refreshToken
|
||||||
}
|
}
|
||||||
|
|
||||||
dbUser.oAuth2 = {
|
dbUser.oauth2 = {
|
||||||
...dbUser.oAuth2,
|
...dbUser.oauth2,
|
||||||
...details,
|
...details,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue