Skip to content

Commit

Permalink
chore: update refresh token in db
Browse files Browse the repository at this point in the history
  • Loading branch information
aaa006bd committed Aug 15, 2023
1 parent e12d434 commit 30d6d18
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/forges/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Gitlab } from './gitlab';
import { Forge as ForgeModel } from '../schemas';
import { Forge as ForgeModel, userForgesSchema } from '../schemas';
import { Github } from './github';
import { Credentials, Forge, ForgeUser, Repo, Tokens, UserWithTokens } from './types';
import jwtDecode from 'jwt-decode';
import { eq } from 'drizzle-orm';

const jwtSecret = '123456789'; // TODO: move to nuxt settings

Expand All @@ -25,7 +26,10 @@ class ForgeApi {
const newTokens = await this.forge.refreshToken(user.tokens.refreshToken);
user.tokens = newTokens;

// TODO: update user tokens in db
await db
.update(userForgesSchema)
.set({ accessToken: newTokens.accessToken, refreshToken: newTokens.refreshToken })
.where(eq(userForgesSchema.userId, user.id)).run();

return newTokens;
}
Expand Down

0 comments on commit 30d6d18

Please sign in to comment.