feat(github): add public repos only login option

closes #133
This commit is contained in:
Rongjian Zhang
2021-01-30 16:18:31 +08:00
parent c1b3d330e0
commit 31c43eebc8
2 changed files with 10 additions and 2 deletions

View File

@@ -728,9 +728,11 @@ class AuthModel with ChangeNotifier {
}
String _oauthState;
void redirectToGithubOauth() {
void redirectToGithubOauth([publicOnly = false]) {
_oauthState = nanoid();
var scope = Uri.encodeComponent('user,repo,read:org,notifications');
final repoScope = publicOnly ? 'public_repo' : 'repo';
final scope = Uri.encodeComponent(
['user', repoScope, 'read:org', 'notifications'].join(','));
launchUrl(
'https://github.com/login/oauth/authorize?client_id=$clientId&redirect_uri=gittouch://login&scope=$scope&state=$_oauthState',
);