Skip to content

Commit

Permalink
feat(github): add public repos only login option
Browse files Browse the repository at this point in the history
closes #133
  • Loading branch information
pd4d10 committed Jan 30, 2021
1 parent c1b3d33 commit 31c43ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/models/auth.dart
Expand Up @@ -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',
);
Expand Down
6 changes: 6 additions & 0 deletions lib/screens/login.dart
Expand Up @@ -157,6 +157,12 @@ class _LoginScreenState extends State<LoginScreen> {
auth.redirectToGithubOauth();
},
),
ActionItem(
text: 'via OAuth (Public repos only)',
onTap: (_) {
auth.redirectToGithubOauth(true);
},
),
ActionItem(
text: 'via Personal token',
onTap: (_) async {
Expand Down

0 comments on commit 31c43ee

Please sign in to comment.