Skip to content

Commit

Permalink
fix: 🎨 Code format
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed May 17, 2022
1 parent b39e892 commit 98c1dea
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions apps/builder/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,24 @@ const updateLastActivityDate = async (user: User) => {
const getUserGroups = async (account: Account): Promise<string[]> => {
switch (account.provider) {
case 'gitlab': {
const getGitlabGroups = async (accessToken: string, page: number = 1): Promise<any[]> => {
const getGitlabGroups = async (
accessToken: string,
page = 1
): Promise<{ full_path: string }[]> => {
const res = await fetch(
`${process.env.GITLAB_BASE_URL || 'https://gitlab.com'}/api/v4/groups?per_page=100&page=${page}`,
`${
process.env.GITLAB_BASE_URL || 'https://gitlab.com'
}/api/v4/groups?per_page=100&page=${page}`,
{ headers: { Authorization: `Bearer ${accessToken}` } }
)
const groups: any[] = await res.json()
const groups: { full_path: string }[] = await res.json()
const nextPage = parseInt(res.headers.get('X-Next-Page') || '')
if (nextPage) {
groups.push(...await getGitlabGroups(accessToken, nextPage))
}
if (nextPage)
groups.push(...(await getGitlabGroups(accessToken, nextPage)))
return groups
}
const groups = await getGitlabGroups(account.access_token!)
return groups.map((group: { full_path: string }) => group.full_path)
const groups = await getGitlabGroups(account.access_token as string)
return groups.map((group) => group.full_path)
}
default:
return []
Expand Down

0 comments on commit 98c1dea

Please sign in to comment.