refactor: Refactor auth provider (#5782)

This commit is contained in:
Bruno Quaresma
2023-01-19 21:02:29 -03:00
committed by GitHub
parent a0a959c7a5
commit ff69c0e70f
39 changed files with 527 additions and 555 deletions
+2 -21
View File
@@ -34,18 +34,6 @@ export const withDefaultFeatures = (
return fs as TypesGen.Entitlements["features"]
}
// defaultEntitlements has a default set of disabled functionality.
export const defaultEntitlements = (): TypesGen.Entitlements => {
return {
features: withDefaultFeatures({}),
has_license: false,
errors: [],
warnings: [],
experimental: false,
trial: false,
}
}
// Always attach CSRF token to all requests.
// In puppeteer the document is undefined. In those cases, just
// do nothing.
@@ -625,15 +613,8 @@ export const putWorkspaceExtension = async (
}
export const getEntitlements = async (): Promise<TypesGen.Entitlements> => {
try {
const response = await axios.get("/api/v2/entitlements")
return response.data
} catch (error) {
if (axios.isAxiosError(error) && error.response?.status === 404) {
return defaultEntitlements()
}
throw error
}
const response = await axios.get("/api/v2/entitlements")
return response.data
}
export const getExperiments = async (): Promise<TypesGen.Experiment[]> => {