Skip to content

Commit

Permalink
step one of AccountChooser integration: adding storeAccount api call and
Browse files Browse the repository at this point in the history
a page to invoke the js.
  • Loading branch information
primmer committed Sep 17, 2012
1 parent 0b8b153 commit be1609a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Guestbook/src/guestbook/UserServlet.java
Expand Up @@ -60,13 +60,14 @@ private void loginRegisteredUser(HttpSession session,
Entity user, HttpServletResponse resp) throws IOException {
if (user != null) {
setUserSession(user, session);
// At the end of a login, always attempt to store the account in
// accountchooser.
resp.sendRedirect("/accountchooser-store.jsp");
} else {
// The user wasn't registered and we don't have fancy form error
// handling.
// handling. Don't store, try to create an account.
resp.sendRedirect("/account-create.jsp");
}
// At the end of a login, go to the homepage.
resp.sendRedirect("/guestbook.jsp");
}

private Entity getUser(DatastoreService datastore, String user_id) {
Expand Down
1 change: 1 addition & 0 deletions Guestbook/war/WEB-INF/.gitignore
@@ -0,0 +1 @@
/appengine-generated
40 changes: 40 additions & 0 deletions Guestbook/war/accountchooser-store.jsp
@@ -0,0 +1,40 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

This comment has been minimized.

Copy link
@Jodyhope

Jodyhope Sep 28, 2015

Mike

<%@ page import="guestbook.UserServlet" %>
<%@ page import="java.util.List" %>
<%@ page import="javax.servlet.http.HttpSession" %>

<%
// The page is loaded at the end of a sign-in or account creation.
// It loads the "save" feature of Account Chooser. The browser is
// redirected to accountchooser.com and has the option to store the
// currently signed in account. If the account is currently stored,
// the ac.js redirects to the homeurl location.
String user_id = (String) session.getAttribute("user_id");
String name = (String) session.getAttribute("name");
String photo = (String) session.getAttribute("photo");
// Don't bother trying to store the account if there's no user_id.
if (user_id == null || user_id.isEmpty()) {
response.sendRedirect("/guestbook.jsp");
}
%>

<html>
<head>

<!-- Begin AC integration -->
<script type="text/javascript" src="https://www.accountchooser.com/ac.js">
storeAccount: {
// After the storeAccount method, redirect to homeUrl"
homeUrl: '/guestbook.jsp',
email: '<%= user_id %>',
displayName: '<%= name %>',
photoUrl: '<%= photo %>'
}
</script>
<!-- End AC integration -->

</head>
<body>
</body>
</html>

1 comment on commit be1609a

@Fazlerabbi71270
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requesting for pull request

Please sign in to comment.