docs: 🐛 stop api call when user is granted
Signed-off-by: slumbering <slumbering.pierrot@gmail.com>
This commit is contained in:
@@ -21,7 +21,7 @@ function bindApiCall({ url, config, errorMessage }) {
|
||||
|
||||
async function getAccessToken(code) {
|
||||
const accessToken = await bindApiCall({
|
||||
url: '/github-proxy/login/oauth/access_token',
|
||||
url: `${process.env.REACT_APP_API_PROXY_ENABLE ? '/github-proxy' : 'https://github.com' }/login/oauth/access_token`,
|
||||
config: {
|
||||
params: {
|
||||
code,
|
||||
@@ -37,7 +37,7 @@ async function getAccessToken(code) {
|
||||
|
||||
export async function getUser(access_token) {
|
||||
const user = await bindApiCall({
|
||||
url: '/github-api-proxy/user',
|
||||
url: `${process.env.REACT_APP_API_PROXY_ENABLE ? '/github-api-proxy' : 'https://api.github.com'}/user`,
|
||||
config: {
|
||||
headers: { Authorization: `token ${access_token}` },
|
||||
},
|
||||
@@ -57,12 +57,11 @@ export async function checkUserCollaboratorStatus(code) {
|
||||
const { login } = await getUser(access_token)
|
||||
|
||||
const isUserCollaborator = await bindApiCall({
|
||||
url: `/docs-access/${login}`,
|
||||
url: `${process.env.REACT_APP_API_PROXY_ENABLE ? '/docs-access' : 'https://j20f3pfq11.execute-api.us-east-1.amazonaws.com/Prod/u'}/${login}`,
|
||||
errorMessage: 'error checkUserCollaboratorStatus'
|
||||
})
|
||||
|
||||
return {
|
||||
isAllowed: isUserCollaborator.data,
|
||||
access_token
|
||||
isAllowed: isUserCollaborator.data
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user