Skip to content

Commit

Permalink
feat(provider): migrate gitlab provider to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannfleurydev committed Jul 16, 2022
1 parent 4ff836a commit 534191f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 22 deletions.
22 changes: 0 additions & 22 deletions packages/next-auth/src/providers/gitlab.js

This file was deleted.

72 changes: 72 additions & 0 deletions packages/next-auth/src/providers/gitlab.ts
@@ -0,0 +1,72 @@
import type { OAuthConfig, OAuthUserConfig } from "."

export interface GitLabProfile extends Record<string, any> {
id: number
username: string
email: string
name: string
state: string
avatar_url: string
web_url: string
created_at: string
bio: string
location?: string
public_email: string
skype: string
linkedin: string
twitter: string
website_url: string
organization: string
job_title: string
pronouns: string
bot: boolean
work_information?: string
followers: number
following: number
local_time: string
last_sign_in_at: string
confirmed_at: string
theme_id: number
last_activity_on: string
color_scheme_id: number
projects_limit: number
current_sign_in_at: string
identities: Array<{
provider: string
extern_uid: string
}>
can_create_group: boolean
can_create_project: boolean
two_factor_enabled: boolean
external: boolean
private_profile: boolean
commit_email: string
shared_runners_minutes_limit: number
extra_shared_runners_minutes_limit: number
}

export default function GitLab<P extends GitLabProfile>(
options: OAuthUserConfig<P>
): OAuthConfig<P> {
return {
id: "gitlab",
name: "GitLab",
type: "oauth",
authorization: {
url: "https://gitlab.com/oauth/authorize",
params: { scope: "read_user" },
},
token: "https://gitlab.com/oauth/token",
userinfo: "https://gitlab.com/api/v4/user",
checks: ["pkce", "state"],
profile(profile) {
return {
id: profile.id.toString(),
name: profile.name ?? profile.username,
email: profile.email,
image: profile.avatar_url,
}
},
options,
}
}

0 comments on commit 534191f

Please sign in to comment.