Subversion Repositories SmartDukaan

Rev

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

Rev 6530 Rev 6788
Line 47... Line 47...
47
        //initMainDB("Testing");
47
        //initMainDB("Testing");
48
        root.add(login);
48
        root.add(login);
49
        login.setLoginListener(new LoginScreen.LoginListener() {
49
        login.setLoginListener(new LoginScreen.LoginListener() {
50
            @Override
50
            @Override
51
            public void onLoginPressed(String username, String password) {
51
            public void onLoginPressed(String username, String password) {
52
                authenticateUser(username, password, Utils.ROLE_STAGING);
52
                authenticateUser(username, password);
53
            }
53
            }
54
        });
54
        });
55
    }
55
    }
56
 
56
 
57
    /**
57
    /**
Line 60... Line 60...
60
     * @param username 
60
     * @param username 
61
     * @param password
61
     * @param password
62
     * @param role -- Utils.ROLE_STAGING (Login role for staging), another role 
62
     * @param role -- Utils.ROLE_STAGING (Login role for staging), another role 
63
     * is Utils.ROLE_PRODUCTION (for push to production username & password)
63
     * is Utils.ROLE_PRODUCTION (for push to production username & password)
64
     */
64
     */
65
    private void authenticateUser(String username, String password, int role) {
65
    private void authenticateUser(String username, String password) {
66
        uname = username;
66
        uname = username;
67
        loginService.authenticateUser(username, password, role, new AsyncCallback<String>() {
67
        loginService.authenticateUser(username, password, new AsyncCallback<String>() {
68
            @Override
68
            @Override
69
            public void onSuccess(String result) {
69
            public void onSuccess(String result) {
70
                if (result != null) {
70
                if (result != null) {
-
 
71
                	long role = Long.parseLong(result);
71
                    GWT.log(result + " logged in catalog dashboard");
72
                    GWT.log(uname + " logged in catalog dashboard");
72
                    root.clear();
73
                    root.clear();
73
                    initMainDB(uname);
74
                    initMainDB(uname, role);
74
                    login.clearFields();
75
                    login.clearFields();
75
                } else {
76
                } else {
76
                    login.setErrorText("Invalid username/password");    
77
                    login.setErrorText("Invalid username/password");    
77
                }
78
                }
78
            }
79
            }
Line 82... Line 83...
82
                login.setErrorText("Error in authentication");
83
                login.setErrorText("Error in authentication");
83
            }
84
            }
84
        });
85
        });
85
    }
86
    }
86
 
87
 
87
    private void initMainDB(String username) {
88
    private void initMainDB(String username, long role) {
88
        DockLayoutPanel dashboard = binder.createAndBindUi(this);
89
        DockLayoutPanel dashboard = binder.createAndBindUi(this);
89
        itemActions.setItemDetails(itemDetails);
90
        itemActions.setItemDetails(itemDetails);
90
        itemList.setItemDetails(itemDetails);
91
        itemList.setItemDetails(itemDetails);
91
        itemDetails.setCatalogDashboardPanel(this);
92
        itemDetails.setCatalogDashboardPanel(this);
92
        topPanel.changeGreeting(username);
93
        topPanel.changeGreeting(username);
-
 
94
        if(role == Utils.ROLE_READONLY){
-
 
95
        	itemActions.disableAllActions();
93
 
96
        }
94
        topPanel.getSignOutLink().addClickHandler(new ClickHandler() {
97
        topPanel.getSignOutLink().addClickHandler(new ClickHandler() {
95
            @Override
98
            @Override
96
            public void onClick(ClickEvent event) {
99
            public void onClick(ClickEvent event) {
97
                root.clear();
100
                root.clear();
98
                root.add(login);
101
                root.add(login);