Skip to content

Commit 2725d07

Browse files
authoredJul 17, 2022
fix(providers): migrate GitLab provider to TS (#4929)
1 parent 5a8b029 commit 2725d07

File tree

2 files changed

+72
-22
lines changed

2 files changed

+72
-22
lines changed
 

‎packages/next-auth/src/providers/gitlab.js

-22
This file was deleted.
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import type { OAuthConfig, OAuthUserConfig } from "."
2+
3+
export interface GitLabProfile extends Record<string, any> {
4+
id: number
5+
username: string
6+
email: string
7+
name: string
8+
state: string
9+
avatar_url: string
10+
web_url: string
11+
created_at: string
12+
bio: string
13+
location?: string
14+
public_email: string
15+
skype: string
16+
linkedin: string
17+
twitter: string
18+
website_url: string
19+
organization: string
20+
job_title: string
21+
pronouns: string
22+
bot: boolean
23+
work_information?: string
24+
followers: number
25+
following: number
26+
local_time: string
27+
last_sign_in_at: string
28+
confirmed_at: string
29+
theme_id: number
30+
last_activity_on: string
31+
color_scheme_id: number
32+
projects_limit: number
33+
current_sign_in_at: string
34+
identities: Array<{
35+
provider: string
36+
extern_uid: string
37+
}>
38+
can_create_group: boolean
39+
can_create_project: boolean
40+
two_factor_enabled: boolean
41+
external: boolean
42+
private_profile: boolean
43+
commit_email: string
44+
shared_runners_minutes_limit: number
45+
extra_shared_runners_minutes_limit: number
46+
}
47+
48+
export default function GitLab<P extends GitLabProfile>(
49+
options: OAuthUserConfig<P>
50+
): OAuthConfig<P> {
51+
return {
52+
id: "gitlab",
53+
name: "GitLab",
54+
type: "oauth",
55+
authorization: {
56+
url: "https://gitlab.com/oauth/authorize",
57+
params: { scope: "read_user" },
58+
},
59+
token: "https://gitlab.com/oauth/token",
60+
userinfo: "https://gitlab.com/api/v4/user",
61+
checks: ["pkce", "state"],
62+
profile(profile) {
63+
return {
64+
id: profile.id.toString(),
65+
name: profile.name ?? profile.username,
66+
email: profile.email,
67+
image: profile.avatar_url,
68+
}
69+
},
70+
options,
71+
}
72+
}

0 commit comments

Comments
 (0)
Please sign in to comment.