Subversion Repositories WebE

Rev

Rev 18 | Rev 20 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 19
Line 1... Line 1...
1
package ch.ffhs.webE.action;
1
package ch.ffhs.webE.action;
2
2
-
 
3
-
 
4
import ch.ffhs.webE.dao.UserDAO;
-
 
5
import ch.ffhs.webE.dao.UserDAOImpl;
-
 
6
import ch.ffhs.webE.domain.User;
-
 
7
3
import com.opensymphony.xwork2.ActionSupport;
8
import com.opensymphony.xwork2.ActionSupport;
-
 
9
import com.opensymphony.xwork2.ModelDriven;
4
10
5
public class LoginAction extends ActionSupport {
11
public class LoginAction extends ActionSupport implements ModelDriven<User>{
6
       
12
       
7
        private static final long serialVersionUID = 1799753056277211344L;
13
        private static final long serialVersionUID = 1799753056277211344L;
-
 
14
        private User user = new User();
-
 
15
        private UserDAO userDAO = new UserDAOImpl();
-
 
16
       
8
       
17
       
9
        private String userName ;
18
        private String userName ;
10
        private String password;       
19
        private String pw;     
11
       
20
       
12
        public LoginAction() {
21
        public LoginAction() {
13
        }
22
        }
14
       
23
       
15
        public String execute() {
24
        public String verifyUser() {
-
 
25
               
16
                //TODO: DB Abfrage für Login
26
                //If password or user name are empty, the login fails.
17
                if("moos".equals(getUserName())) {
27
                if("".equals(getUserName()) || "".equals(getPw()) || getUserName() == null || getPw() == null) {
18
                        return "success";
28
                        return "failed";
19
                } else {
29
                }
-
 
30
               
-
 
31
                User u = userDAO.searchUsername(getUserName());
-
 
32
               
-
 
33
                if(u == null)
20
                        return "failed";
34
                        return "failed";
-
 
35
               
-
 
36
                if(!u.getPassword().equals(getPw()))
-
 
37
                        return "failed";
-
 
38
               
-
 
39
                if(u.isAdmin()) {
-
 
40
                        return "admin";
-
 
41
                } else {
-
 
42
                        return "user";
21
                }
43
                }
22
        }
44
        }
23
       
45
       
24
        public String getUserName() {
46
        public String getUserName() {
25
                return userName;
47
                return userName;
26
        }
48
        }
27
49
28
        public void setUserName(String userName) {
50
        public void setUserName(String userName) {
29
                this.userName = userName;
51
                this.userName = userName;
30
        }
52
        }
-
 
53
       
-
 
54
        public String getPw() {
-
 
55
                return pw;
-
 
56
        }
31
57
32
        public String getPassword() {
58
        public void setPw(String pw) {
33
                return password;
59
                this.pw = pw;
34
        }
60
        }
-
 
61
-
 
62
        @Override
35
        public void setPassword(String password) {
63
        public User getModel() {
36
                this.password = password;
64
                return user;
37
        }
65
        }
38
66
39
       
67
       
40
       
68
       
41
69