largegittest2
bunsenstraat 3 months ago
parent 7d3300c6f0
commit ae0b394e41
  1. 19
      apps/remix-ide/src/app/files/dgitProvider.ts
  2. 8
      libs/remix-ui/git/src/components/panels/githubcredentials.tsx

@ -1056,24 +1056,25 @@ class DGitProvider extends Plugin {
auth: input.token
})
const user = await octokit.request('GET /user')
const user = await octokit.request('GET /user', {
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
const emails = await octokit.request('GET /user/emails')
const scopes = user.headers['x-oauth-scopes'] || ''
console.log(scopes)
const scopesArr = scopes.split(',').map(scope => scope.trim())
console.log(scopesArr)
return {
user: { ...user.data, isConnected:
scopes
&& scopesArr.includes('repo')
&& scopesArr.includes('read:user')
&& scopesArr.includes('user:email')
&& scopesArr.includes('gist')
user: {
...user.data, isConnected:
user.data.login !== undefined && user.data.login !== null && user.data.login !== ''
},
emails: emails.data,
scopes: scopes && scopes.split(',')
scopes: scopes && scopes.split(',').map(scope => scope.trim())
}
} catch (e) {
return null

@ -22,7 +22,11 @@ export const GitHubCredentials = () => {
useEffect(() => {
refresh()
if (context.gitHubUser) {
setScopeWarning(!context.gitHubUser.isConnected)
setScopeWarning(!(context.gitHubScopes
&& context.gitHubScopes.includes('repo')
&& context.gitHubScopes.includes('read:user')
&& context.gitHubScopes.includes('user:email')
&& context.gitHubScopes.includes('gist')))
} else {
setScopeWarning(false)
}
@ -92,7 +96,7 @@ export const GitHubCredentials = () => {
</button>
</div>
{scopeWarning ?
<div className="text-warning">Your GitHub token may not have the correct permissions. Please use the login with GitHub feature.</div> : null}
<div className="text-warning">Your GitHub token may or may not have the correct permissions. Remix can't verify the permissions when using your own token. Please use the login with GitHub feature.</div> : null}
<hr />
</>
);

Loading…
Cancel
Save