Author: alevkovsky
Date: 2009-03-30 10:25:46 -0400 (Mon, 30 Mar 2009)
New Revision: 13298
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/login.xhtml
Log:
Realworld: correct authentication
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-03-30
14:22:03 UTC (rev 13297)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-03-30
14:25:46 UTC (rev 13298)
@@ -22,6 +22,7 @@
import java.io.Serializable;
+import javax.faces.context.FacesContext;
import javax.security.auth.login.LoginException;
import org.jboss.seam.ScopeType;
@@ -75,8 +76,11 @@
@In FileManager fileManager;
@In @Out Model model;
+
+ private boolean loginFailed = false;
public String login(){
+ setLoginFailed(false);
if(identity.hasRole("admin")){
//TODO nick - return null
return "";
@@ -89,10 +93,11 @@
try {
identity.authenticate();
//TODO nick - maybe clearShelves() before trying to aunthenticate?
- shelfManager.clearShelfs();
+ shelfManager.clearShelfs();
} catch (LoginException e) {
- // TODO nick - Auto-generated catch block
- e.printStackTrace();
+ setLoginFailed(true);
+ identity.addRole(Constants.GUEST_ROLE);
+ FacesContext.getCurrentInstance().renderResponse();
}
return "main";
}
@@ -168,4 +173,14 @@
public Long getStartConversation() {
return startConversation;
}
+
+ public boolean isLoginFailed() {
+ return loginFailed;
+ }
+
+ public void setLoginFailed(boolean loginFailed) {
+ this.loginFailed = loginFailed;
+ }
+
+
}
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/login.xhtml
===================================================================
(Binary files differ)
Show replies by date