Subversion Repositories SmartDukaan

Rev

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