Skip to content

Commit

Permalink
refactor getUserIdByGithubId を抽象化
Browse files Browse the repository at this point in the history
  • Loading branch information
a01sa01to committed Nov 10, 2024
1 parent e2aeed7 commit 7830a3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion webapp/api/cb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ app.get(
}

// すでになければ DB にユーザー情報を格納
const oauthConnInfo = await c.var.idpClient.getUserIdByGithubId(user.id)
const oauthConnInfo = await c.var.idpClient.getUserIdByOauthId(
1,
String(user.id),
)
if (!oauthConnInfo) {
const uuid = crypto.randomUUID().replaceAll('-', '')
// とりあえず仮情報で埋める
Expand Down
7 changes: 4 additions & 3 deletions webapp/repository/idp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ export class IdpRepository {
return await this.getStmt.userById.bind(id).first()
}

async getUserIdByGithubId(
githubId: number,
async getUserIdByOauthId(
oauthProviderId: number,
oauthUserId: string,
): Promise<{ user_id: string } | null> {
return await this.getStmt.userIdByOauthId
.bind(1, githubId.toString())
.bind(oauthProviderId, oauthUserId)
.first()
}

Expand Down

0 comments on commit 7830a3c

Please sign in to comment.