Subversion Repositories SmartDukaan

Rev

Rev 1051 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1051 rajveer 1
/**
2
 * 
3
 */
4
package in.shop2020.creation.controllers;
5
import in.shop2020.content.security.UserManager;
6
import java.io.IOException;
7
import java.util.Map;
8
 
9
import org.apache.struts2.convention.annotation.Result;
10
 
11
/**
12
 * 
13
 * @author rajveer
14
 * 
15
 */
16
 
17
@Result(name="success", type="redirectAction", params = {"actionName" , "entity"})
18
 
19
 
20
public class LoginController extends BaseController {
21
 
22
	/**
23
	 * 
24
	 */
25
	private static final long serialVersionUID = 5390035354379263121L;
26
 
27
 
28
 
29
	public String index() throws SecurityException, IOException {
30
		return "index";
31
	}
32
 
33
	public String create() throws SecurityException, Exception {
34
		if (loginUser()) {
35
			return "success";
36
		} else {
37
			addActionError("Wrong username or password.");
38
			return "index";
39
		}
40
	}
41
 
42
	private boolean loginUser() {
43
		try{
44
			String username = this.reqparams.get("username")[0];
45
			String password = this.reqparams.get("password")[0];
46
			if(UserManager.getUserManager().authenticateUser(username, password)){
47
				setUserAsLogin(username);
48
				return true;
49
			}
50
		}catch(Exception exp){
51
 
52
		}
53
		return false;
54
	}
55
 
56
}