Skip to content

Commit

Permalink
fix: Switch BattleNet to OIDC (#4015)
Browse files Browse the repository at this point in the history
* Fixes: #4013

* Update packages/next-auth/src/providers/battlenet.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update packages/next-auth/src/providers/battlenet.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update packages/next-auth/src/providers/battlenet.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Apply suggestions from code review

* Update battlenet.ts

* Update battlenet.ts

* Update battlenet.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>
  • Loading branch information
Stono and balazsorban44 committed Feb 22, 2022
1 parent 21f4104 commit 75cb175
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
26 changes: 0 additions & 26 deletions packages/next-auth/src/providers/battlenet.js

This file was deleted.

35 changes: 35 additions & 0 deletions packages/next-auth/src/providers/battlenet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { OAuthConfig, OAuthUserConfig } from "."

export interface BattleNetProfile {
sub: string
battle_tag: string
}

export default function BattleNet<
P extends Record<string, any> = BattleNetProfile
>(
options: OAuthUserConfig<P> & {
region: "US" | "EU" | "KR" | "TW" | "CN"
}
): OAuthConfig<P> {
const { region } = options
const domain =
region === "CN"
? "https://www.battlenet.com.cn"
: `https://${region}.battle.net`

return {
id: "battlenet",
name: "Battle.net",
wellKnown: `${domain}/oauth/.well-known/openid-configuration`,
profile(profile) {
return {
id: profile.sub,
name: profile.battle_tag,
email: null,
image: null,
}
},
options,
}
}

0 comments on commit 75cb175

Please sign in to comment.