Subversion Repositories SmartDukaan

Rev

Rev 1081 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1081 Rev 7286
Line 1... Line 1...
1
/**
1
/**
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.creation.controllers;
4
package in.shop2020.creation.controllers;
-
 
5
import in.shop2020.content.security.Role;
5
import in.shop2020.content.security.UserManager;
6
import in.shop2020.content.security.UserManager;
-
 
7
 
6
import java.io.IOException;
8
import java.io.IOException;
-
 
9
import java.util.ArrayList;
7
import java.util.Map;
10
import java.util.Arrays;
8
 
11
 
9
import org.apache.struts2.convention.annotation.Result;
12
import org.apache.struts2.convention.annotation.Result;
10
 
13
 
11
/**
14
/**
12
 * 
15
 * 
13
 * @author rajveer
16
 * @author rajveer
14
 * 
17
 * 
15
 */
18
 */
16
 
19
 
17
@Result(name="success", type="redirectAction", params = {"actionName" , "entity"})
20
@Result(name="success", type="redirectAction", params = {"actionName" , "${url}"})
18
 
21
 
19
 
22
 
20
public class LoginController extends BaseController {
23
public class LoginController extends BaseController {
21
 
24
 
22
	/**
25
	/**
23
	 * 
26
	 * 
24
	 */
27
	 */
25
	private static final long serialVersionUID = 5390035354379263121L;
28
	private static final long serialVersionUID = 5390035354379263121L;
-
 
29
	private String url = "";
26
 
30
 
27
 
31
 
28
	
32
	
29
	public String index() throws SecurityException, IOException {
33
	public String index() throws SecurityException, IOException {
30
		return "index";
34
		return "index";
31
	}
35
	}
32
 
36
 
33
	public String create() throws SecurityException, Exception {
37
	public String create() throws SecurityException, Exception {
34
		if (loginUser()) {
38
		if (loginUser()) {
-
 
39
			Role r = UserManager.getUserManager().getUserRole(getUsername());
-
 
40
			if(new ArrayList<Role>(Arrays.asList(Role.ADMIN,Role.DEVELOPER, Role.EDITOR)).contains(r)) {
-
 
41
				this.url = "entity";
-
 
42
			}else {
-
 
43
				this.url = "expert-review";
-
 
44
			}
35
			return "success";
45
			return "success";
36
		} else {
46
		} else {
37
			addActionError("Wrong username or password.");
47
			addActionError("Wrong username or password.");
38
			return "index";
48
			return "index";
39
		}
49
		}
Line 50... Line 60...
50
		}catch(Exception exp){
60
		}catch(Exception exp){
51
			
61
			
52
		}
62
		}
53
		return false;
63
		return false;
54
	}
64
	}
-
 
65
	
-
 
66
	public String getUrl(){
-
 
67
		return this.url;
-
 
68
	}
55
 
69
 
56
}
70
}