Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ export const ConfigureGitlabModalBody: FC<{

const checkDomainWithRegex = (domain: string) => {
const regex =
/^(https:\/\/)?[a-zA-Z0-9]+([-.][a-zA-Z0-9]+)*\.[a-zA-Z]{2,}(:[0-9]{1,5})?(\/.*)?$/;
/^(https?:\/\/)[a-zA-Z0-9]+([-.][a-zA-Z0-9]+)*\.[a-zA-Z]{2,}(:[0-9]{1,5})?(\/.*)?$/;
return regex.test(domain);
};

const handleTokenChange = (e: string) => {
token.set(e);
showScopeError.set('');
Expand Down Expand Up @@ -79,7 +78,7 @@ export const ConfigureGitlabModalBody: FC<{
}

depFn(isLoading.true);
await checkGitLabValidity(token.value)
await checkGitLabValidity(token.value, customDomain.value)
.then(async (res) => {
return res;
})
Expand Down
8 changes: 6 additions & 2 deletions web-server/src/utils/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ export const getMissingPATScopes = async (pat: string) => {

// Gitlab functions

export const checkGitLabValidity = async (accessToken: string) => {
const url = 'https://gitlab.com/api/v4/personal_access_tokens/self';
export const checkGitLabValidity = async (
accessToken: string,
customDomain?: string
) => {
const baseUrl = customDomain || 'https://gitlab.com';
const url = `${baseUrl}/api/v4/personal_access_tokens/self`;
try {
const response = await axios.get(url, {
headers: {
Expand Down
Loading