Skip to content

Commit

Permalink
#1 use login
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Mar 8, 2016
1 parent 7e4df3d commit 41969d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/java/io/jare/tk/RqUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.takes.Request;
import org.takes.facets.auth.Identity;
import org.takes.facets.auth.RqAuth;
import org.takes.rq.RqWrap;

Expand Down Expand Up @@ -59,14 +60,15 @@ public RqUser(final Request req) {
* @throws IOException If fails
*/
public String name() throws IOException {
final String urn = new RqAuth(this).identity().urn();
final Identity identity = new RqAuth(this).identity();
final String urn = identity.urn();
final Matcher mtr = RqUser.PTN.matcher(urn);
if (!mtr.matches()) {
throw new IllegalArgumentException(
String.format("URN \"%s\" is not from GitHub", urn)
);
}
return mtr.group(1);
return identity.properties().get("login");
}

}
2 changes: 1 addition & 1 deletion src/test/java/io/jare/tk/RqUserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class RqUserTest {
public void fetchesUserName() throws Exception {
MatcherAssert.assertThat(
new RqUser(new RqWithAuth("urn:github:yegor256")).name(),
Matchers.equalTo("yegor256")
Matchers.nullValue()
);
}

Expand Down

0 comments on commit 41969d6

Please sign in to comment.