Subversion Repositories WebE

Compare Revisions

Last modification

Ignore whitespace Rev 20 → Rev 19

/trunk/src/ch/ffhs/webE/action/UserAction.java
File deleted
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property
Index: UserForm.java
===================================================================
--- UserForm.java (revision 20)
+++ UserForm.java (nonexistent)
@@ -1,73 +0,0 @@
-package ch.ffhs.webE.action;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.struts2.components.ActionError;
-import org.apache.struts2.dispatcher.mapper.ActionMapping;
-
-import com.opensymphony.xwork2.ActionSupport;
-
-public class UserForm extends ActionSupport {
-
- private static final long serialVersionUID = 2574972467250197244L;
-
- private String username;
- private String password;
- private String firstname;
- private String lastname;
- private boolean admin;
-
- public void reset(ActionMapping mapping, HttpServletRequest request) {
- this.username = null;
- this.password = null;
- this.firstname = null;
- this.lastname = null;
- this.admin = false;
- }
-
- public void validate() {
-
- }
-
-
- // Getter and setters
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getFirstname() {
- return firstname;
- }
-
- public void setFirstname(String firstname) {
- this.firstname = firstname;
- }
-
- public String getLastname() {
- return lastname;
- }
-
- public void setLastname(String lastname) {
- this.lastname = lastname;
- }
-
- public boolean isAdmin() {
- return admin;
- }
-
- public void setAdmin(boolean admin) {
- this.admin = admin;
- }
-}
/UserForm.java
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property
Index: LoginAction.java
===================================================================
--- LoginAction.java (revision 20)
+++ LoginAction.java (revision 19)
@@ -1,13 +1,10 @@
package ch.ffhs.webE.action;
-import java.util.Map;
-
import ch.ffhs.webE.dao.UserDAO;
import ch.ffhs.webE.dao.UserDAOImpl;
import ch.ffhs.webE.domain.User;
-import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
@@ -17,60 +14,28 @@
private User user = new User();
private UserDAO userDAO = new UserDAOImpl();
- //Form fields
+
private String userName ;
private String pw;
-
- //Session Object
- Map<String, Object> session = ActionContext.getContext().getSession();
-
public LoginAction() {
}
- public String doLogin() {
+ public String verifyUser() {
//If password or user name are empty, the login fails.
if("".equals(getUserName()) || "".equals(getPw()) || getUserName() == null || getPw() == null) {
return "failed";
- }
+ }
- String verifiedUser = verifyUser(getUserName(), getPw());
- if(verifiedUser.equals("failed")) {
- return "failed";
- } else {
-
- //Put user name, password into session
- session.put("username", getUserName());
- session.put("pw", getPw());
- return verifiedUser;
- }
- }
-
- public String doLogout() {
- //TODO: Kill session content for logout
- return SUCCESS;
- }
-
- /**
- * Verify user credentials
- * @param String username: User name
- * @param String password: Password (hashed)
- * @return
- */
- public String verifyUser(String username, String password) {
- //DB Query
- User u = userDAO.searchUsername(username);
+ User u = userDAO.searchUsername(getUserName());
- //User does not exist
if(u == null)
return "failed";
- //User password does not match
- if(!u.getPassword().equals(password))
+ if(!u.getPassword().equals(getPw()))
return "failed";
- //User credentials are fine, check for admin rights
if(u.isAdmin()) {
return "admin";
} else {