summaryrefslogtreecommitdiffstats
path: root/extensions/GitHubAuth/lib
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-09-01 08:41:37 +0200
committerByron Jones <glob@mozilla.com>2015-09-01 08:41:37 +0200
commit20eabc1e5bc502e36c1b3f3ed4fa259c23b62bc3 (patch)
treec93ba6a20e1c776b44529305caf15928d08f6ae9 /extensions/GitHubAuth/lib
parent421ff7f194875db9634ea783d9dd5b6111f19df3 (diff)
downloadbugzilla-20eabc1e5bc502e36c1b3f3ed4fa259c23b62bc3.tar.gz
bugzilla-20eabc1e5bc502e36c1b3f3ed4fa259c23b62bc3.tar.xz
Bug 1200515 - unable to create accounts with github
Diffstat (limited to 'extensions/GitHubAuth/lib')
-rw-r--r--extensions/GitHubAuth/lib/Login.pm35
1 files changed, 23 insertions, 12 deletions
diff --git a/extensions/GitHubAuth/lib/Login.pm b/extensions/GitHubAuth/lib/Login.pm
index 933dc6572..6e105c33a 100644
--- a/extensions/GitHubAuth/lib/Login.pm
+++ b/extensions/GitHubAuth/lib/Login.pm
@@ -54,17 +54,28 @@ sub get_login_info {
}
if (!exists $response->{failure}) {
- my $user = $response->{user};
- return { failure => AUTH_ERROR,
- user_error => 'github_auth_account_too_powerful' } if $user->in_group('no-github-auth');
- return { failure => AUTH_ERROR,
- user_error => 'mfa_prevents_login',
- details => { provider => 'GitHub' } } if $user->mfa;
- $response = {
- username => $user->login,
- user_id => $user->id,
- github_auth => 1,
- };
+ if (exists $response->{user}) {
+ # existing account
+ my $user = $response->{user};
+ return { failure => AUTH_ERROR,
+ user_error => 'github_auth_account_too_powerful' } if $user->in_group('no-github-auth');
+ return { failure => AUTH_ERROR,
+ user_error => 'mfa_prevents_login',
+ details => { provider => 'GitHub' } } if $user->mfa;
+ $response = {
+ username => $user->login,
+ user_id => $user->id,
+ github_auth => 1,
+ };
+ }
+ else {
+ # new account
+ my $email = $response->{email};
+ $response = {
+ username => $email,
+ github_auth => 1,
+ };
+ }
}
return $response;
}
@@ -177,7 +188,7 @@ sub _get_login_info_from_email {
my $user = Bugzilla::User->new({name => $github_email, cache => 1});
$cgi->remove_cookie('Bugzilla_github_token');
- return { user => $user };
+ return $user ? { user => $user } : { email => $github_email };
}
sub fail_nodata {