diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2013-08-27 08:28:16 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2013-08-27 08:28:16 -0700 |
commit | 1cdb43bb3e432040aed18c05e129f0131ee7d20a (patch) | |
tree | a4c5ad41d183b3874c990de0c5416d1810a1dc85 /src/com/p4square/grow/frontend/LoginPageResource.java | |
parent | 9b33aaf27cd8f73402ee9967c6b0fd76a90f8ebe (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.java | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/src/com/p4square/grow/frontend/LoginPageResource.java b/src/com/p4square/grow/frontend/LoginPageResource.java index 70caa3e..e645c1b 100644 --- a/src/com/p4square/grow/frontend/LoginPageResource.java +++ b/src/com/p4square/grow/frontend/LoginPageResource.java @@ -17,7 +17,7 @@ import org.restlet.ext.freemarker.TemplateRepresentation; import org.apache.log4j.Logger; -import net.jesterpm.fmfacade.FreeMarkerPageResource; +import com.p4square.fmfacade.FreeMarkerPageResource; /** * LoginPageResource presents a login page template and processes the response. @@ -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(); - } - } } |