Skip to content

Commit

Permalink
Use user.getAttribute(key) method to retrieve the email in the auth…
Browse files Browse the repository at this point in the history
…entication examples
  • Loading branch information
besidev committed Mar 15, 2024
1 parent 6b14956 commit b36d4ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public SignedInPage(GoogleLoginApp app, OAuth2AuthenticationProvider authProvide
if (user == null) {
getChildren().add(headerLabel);
} else {
headerLabel.setText("Signed in as user: " + user.getName() + "\n(" + user.getEmail() + ")");
headerLabel.setText("Signed in as user: " + user.getName() + "\n(" + user.getAttribute("email") + ")");

final var userInfoTextArea = new TextArea();
userInfoTextArea.setWrapText(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ public SignedInUserPage(OAuthApp loginApp) {
getChildren().add(headerLabel);
} else {
final User user = loginApp.getUserSession().getUser();
if (user == null) {
headerLabel.setText("Not signed in.");
} else {
headerLabel.setText("Signed in user: " + user.getName() + "\n(" + user.getEmail() + ")");
}
headerLabel.setText(user == null ? "Not signed in." :
"Signed in user: " + user.getName() + "\n(" + user.getAttribute("email") + ")");

final var authInfoBox = loginApp.createButtonWithDescription(
"Show authentication information about this user.", "Auth Info",
event -> gotoPage(headerLabel, "/user/auth-info"));

final var introspectTokenBox = loginApp.createButtonWithDescription(
"Introspect the access token.", "Introspect Token",
event -> FXFuture.fromJava(authProvider.introspect(loginApp.getUserSession().getUser(), "access_token"))
event -> FXFuture.fromJava(authProvider.introspect(loginApp.getUserSession().getUser(),
"access_token"))
.map(json -> {
loginApp.setIntrospectionInfo(json);
gotoPage(headerLabel, "/user/introspect-token");
Expand Down

0 comments on commit b36d4ed

Please sign in to comment.