Fix email, add response to account handler. This requires https://github.com/kohsuke/github-api/pull/87 Change-Id: Icf778858ca2fc3ed540c86ffa1b3eb7be81ff9a7
diff --git a/github-oauth/pom.xml b/github-oauth/pom.xml index 96bab29..b089af9 100644 --- a/github-oauth/pom.xml +++ b/github-oauth/pom.xml
@@ -107,7 +107,7 @@ <dependency> <groupId>org.kohsuke</groupId> <artifactId>github-api</artifactId> - <version>1.50</version> + <version>1.52-SNAPSHOT</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId>
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java index cb2be5d..b37cc42 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java
@@ -75,8 +75,15 @@ public void doAction(IdentifiedUser user, GitHubLogin hubLogin, HttpServletRequest req, HttpServletResponse resp, ControllerErrors errors) throws ServletException, IOException { - setAccountIdentity(user, req); - setAccoutPublicKeys(user, hubLogin, req); + try { + setAccountIdentity(user, req); + setAccoutPublicKeys(user, hubLogin, req); + + log.info("Created account '" + user.getUserName() + "'"); + } catch (IOException e) { + log.error("Account '" + user.getUserName() + "' creation failed", e); + throw e; + } } private void setAccountIdentity(IdentifiedUser user, HttpServletRequest req) throws ServletException { @@ -90,7 +97,7 @@ dbProvider.get().accounts().update(Collections.singleton(a)); accountCache.evict(user.getAccountId()); } catch (AccountException | OrmException e) { - throw new ServletException("Cannot associated email '" + email + throw new ServletException("Cannot associate email '" + email + "' to current user '" + user + "'", e); } }
diff --git a/github-plugin/src/main/resources/static/account.html b/github-plugin/src/main/resources/static/account.html index e352ebd..f39d8aa 100644 --- a/github-plugin/src/main/resources/static/account.html +++ b/github-plugin/src/main/resources/static/account.html
@@ -53,10 +53,10 @@ <li><label for="eMail">e-Mail:</label> <select id="email" name="email"> #foreach ( $email in $myself.emails ) - #if ( $email == $!myself.email ) - <option selected="selected">$email</option> + #if ( $email.email == $!myself.email || $email.primary ) + <option selected="selected">$email.email</option> #else - <option>$email</option> + <option>$email.email</option> #end #end </select>