summaryrefslogtreecommitdiff
path: root/src/com/p4square/grow/frontend/LoginPageResource.java
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2013-08-27 08:28:16 -0700
committerJesse Morgan <jesse@jesterpm.net>2013-08-27 08:28:16 -0700
commit362cef066725dec0ffaeacb91e7e3c287d68bc51 (patch)
tree712fa205868adf14ebe08ba24dffdd72bfe616dc /src/com/p4square/grow/frontend/LoginPageResource.java
parent9b33aaf27cd8f73402ee9967c6b0fd76a90f8ebe (diff)
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.
Diffstat (limited to 'src/com/p4square/grow/frontend/LoginPageResource.java')
-rw-r--r--src/com/p4square/grow/frontend/LoginPageResource.java38
1 files changed, 5 insertions, 33 deletions
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<String, Object> 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();
- }
- }
}