From 362cef066725dec0ffaeacb91e7e3c287d68bc51 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Tue, 27 Aug 2013 08:28:16 -0700 Subject: Introducing F1 Authentication and Adding Site Content. This change introduced the f1oauth and jesterpm oauth packages for interacting with Fellowship One's developer API. I have also reworked the login authentication to verify credentials through F1 and added session management to track logged in users. The Authenticator chain works as follows: on every page load we check for a session cookie, if the cookie exists, the Request is marked as authenticated and the OAuthUser object is restored in ClientInfo. If this request is going to an account page, we require authentication. The LoginFormAuthenticator checks if the user is already authenticated (via cookie) and if not redirects the user to the login page. When the login form is submitted, LoginFormAuthenticator catches the POST request and authenticates the user through F1. I'm also adding a new account page, but it is currently a work in progress. This commit also adds Allen's content to the site. --- .../p4square/grow/frontend/LoginPageResource.java | 38 +++------------------- 1 file changed, 5 insertions(+), 33 deletions(-) (limited to 'src/com/p4square/grow/frontend/LoginPageResource.java') diff --git a/src/com/p4square/grow/frontend/LoginPageResource.java b/src/com/p4square/grow/frontend/LoginPageResource.java index 70caa3e..3eaff65 100644 --- a/src/com/p4square/grow/frontend/LoginPageResource.java +++ b/src/com/p4square/grow/frontend/LoginPageResource.java @@ -57,7 +57,11 @@ public class LoginPageResource extends FreeMarkerPageResource { Map root = getRootObject(); - root.put("errorMessage", mErrorMessage); + Form query = getRequest().getOriginalRef().getQueryAsForm(); + String retry = query.getFirstValue("retry"); + if ("t".equals("retry")) { + root.put("errorMessage", "Invalid email or password."); + } return new TemplateRepresentation(t, root, MediaType.TEXT_HTML); @@ -68,36 +72,4 @@ public class LoginPageResource extends FreeMarkerPageResource { } } - /** - * Process login and authenticate the user. - */ - @Override - protected Representation post(Representation entity) { - final Form form = new Form(entity); - final String email = form.getFirstValue("email"); - final String password = form.getFirstValue("password"); - - boolean authenticated = false; - - // TODO: Do something real here - if (email != null && !"".equals(email)) { - cLog.debug("Got login request from " + email); - - // TODO: Encrypt user info - getResponse().getCookieSettings().add(LoginAuthenticator.COOKIE_NAME, email); - - authenticated = true; - } - - if (authenticated) { - // TODO: Better return url. - getResponse().redirectSeeOther(mGrowFrontend.getConfig().getString("dynamicRoot", "") + "/index.html"); - return null; - - } else { - // Send them back to the login page... - mErrorMessage = "Incorrect Email or Password."; - return get(); - } - } } -- cgit v1.2.3