Subversion Repositories SmartDukaan

Rev

Rev 3390 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3090 mandeep.dh 1
/**
2
 * 
3
 */
4
package in.shop2020.serving.controllers;
5
 
5053 mandeep.dh 6
import in.shop2020.serving.auth.CRMAuthorizingRealm;
3390 mandeep.dh 7
import in.shop2020.thrift.clients.CRMClient;
8
 
3090 mandeep.dh 9
import org.apache.shiro.SecurityUtils;
10
import org.apache.shiro.crypto.hash.Sha256Hash;
11
import org.apache.struts2.convention.annotation.Result;
12
import org.apache.thrift.TException;
13
 
14
/**
15
 * @author mandeep
16
 * This class manages all the login related updates for a user.
17
 */
18
@Result(name="loginPage", location="/login.html")
19
public class LoginController extends BaseController {
20
 
21
    /**
22
     * 
23
     */
24
    private static final long serialVersionUID = 1L;
25
 
26
    private String password; 
27
 
28
    public String updatePassword() throws TException
29
    {
3390 mandeep.dh 30
        crmServiceClient = new CRMClient().getClient();
3090 mandeep.dh 31
        crmServiceClient.updatePasswordForAgent(currentAgentEmailId, new Sha256Hash(password).toHex());
32
        addActionMessage("Password changed successfully!");
5053 mandeep.dh 33
 
34
        // Dummy call to reload agents
35
        CRMAuthorizingRealm.getAgent(-1);
3090 mandeep.dh 36
        return INPUT;
37
    }
38
 
39
    public String logout()
40
    {
41
        log.info("Logging out!");
42
        SecurityUtils.getSubject().logout();
43
        return "loginPage";
44
    }
3106 mandeep.dh 45
 
46
    public String getPassword() {
47
        return password;
48
    }
49
 
50
    public void setPassword(String password) {
51
        this.password = password;
52
    }
3269 mandeep.dh 53
 
54
    public static void main(String[] args) {
55
        if (args != null && args.length != 0) {
56
            System.out.println(new Sha256Hash(args[0]).toHex());
57
        }
58
    }
3090 mandeep.dh 59
}