Subversion Repositories SmartDukaan

Rev

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

Rev 3830 Rev 4453
Line 64... Line 64...
64
    	else
64
    	else
65
    		return "failure";
65
    		return "failure";
66
    }
66
    }
67
    
67
    
68
    public boolean registerUser() throws Exception{
68
    public boolean registerUser() throws Exception{
69
    	String email, password, userName;
69
    	String email, password;
70
    	boolean isValid = true;
70
    	boolean isValid = true;
71
    	userName =  this.request.getParameter("nameOfUser");
-
 
72
    	email = this.request.getParameter("email"); 
71
    	email = this.request.getParameter("email"); 
73
    	password = this.request.getParameter("txtPassword");
72
    	password = this.request.getParameter("txtPassword");
74
    	
73
    	
75
    	if(userName == null ){
-
 
76
    		addActionError("Please enter name of user.");
-
 
77
    		isValid = false;
-
 
78
        }
-
 
79
    	if(email == null ){
74
    	if(email == null ){
80
    		addActionError("Please enter valid email.");
75
    		addActionError("Please enter valid email.");
81
    		isValid = false;
76
    		isValid = false;
82
        }
77
        }
83
    	if(password == null ){
78
    	if(password == null ){
84
    		addActionError("Please enter password.");
79
    		addActionError("Please enter password.");
85
    		isValid = false;
80
    		isValid = false;
86
        }
81
        }
87
    	
82
    	
88
    	if(!isValid){
83
    	if(!isValid){
89
    	    DataLogger.logData(EventType.REGISTER_DATA_INCOMPLETE, getSessionId(), userinfo.getUserId(), email, userName, email);
84
    	    DataLogger.logData(EventType.REGISTER_DATA_INCOMPLETE, getSessionId(), userinfo.getUserId(), email, "", email);
90
    		return isValid;
85
    		return isValid;
91
    	}
86
    	}
92
    	
87
    	
93
		UserClient userContextServiceClient = new UserClient();
88
		UserClient userContextServiceClient = new UserClient();
94
		in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
89
		in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
95
 
90
 
96
		if(userClient.userExists(email)){
91
		if(userClient.userExists(email)){
97
			addActionError("User already exists with this email id.");
92
			addActionError("User already exists with this email id.");
98
			DataLogger.logData(EventType.REGISTER_FAILED_USER_EXISTS, getSessionId(), userinfo.getUserId(), email, userName, email);
93
			DataLogger.logData(EventType.REGISTER_FAILED_USER_EXISTS, getSessionId(), userinfo.getUserId(), email, "", email);
99
			return false;
94
			return false;
100
		}
95
		}
101
 
96
 
102
		User user = new User();
97
		User user = new User();
103
		user.setName(userName);
-
 
104
		user.setEmail(email);
98
		user.setEmail(email);
105
		String encryptedPassword = desEncrypter.encrypt(password);
99
		String encryptedPassword = desEncrypter.encrypt(password);
106
		user.setPassword(encryptedPassword);
100
		user.setPassword(encryptedPassword);
107
		user.setCommunicationEmail(email);
101
		user.setCommunicationEmail(email);
108
		Cookie sourceCookie = (Cookie) cookiesMap.get(TrackingInterceptor.SRC_COOKIE);
102
		Cookie sourceCookie = (Cookie) cookiesMap.get(TrackingInterceptor.SRC_COOKIE);
Line 154... Line 148...
154
				}
148
				}
155
			}
149
			}
156
		}
150
		}
157
		
151
		
158
		userinfo.setUserId(userId);
152
		userinfo.setUserId(userId);
159
		userinfo.setNameOfUser(userName);
-
 
160
		userinfo.setEmail(email);
153
		userinfo.setEmail(email);
161
		userinfo.setLoggedIn(true);
154
		userinfo.setLoggedIn(true);
162
		userinfo.setPincode(pincode);
155
		userinfo.setPincode(pincode);
163
		userinfo.setCartId(user.getActiveCartId());
156
		userinfo.setCartId(user.getActiveCartId());
164
		Cart cart = userClient.getCart(userinfo.getCartId());
157
		Cart cart = userClient.getCart(userinfo.getCartId());
Line 167... Line 160...
167
		
160
		
168
        if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
161
        if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
169
            long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
162
            long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
170
            userClient.addTrackLog(affId, userId, TrackLogType.NEW_REGISTRATION, "",email, (new Date()).getTime());
163
            userClient.addTrackLog(affId, userId, TrackLogType.NEW_REGISTRATION, "",email, (new Date()).getTime());
171
        }
164
        }
172
        DataLogger.logData(EventType.REGISTER_SUCCESS, getSessionId(), userinfo.getUserId(), email, userName, email);
165
        DataLogger.logData(EventType.REGISTER_SUCCESS, getSessionId(), userinfo.getUserId(), email, "", email);
173
 
166
 
174
		return true;
167
		return true;
175
    }
168
    }
176
 
169
 
177
	public String getRegistrationHeaderSnippet(){
170
	public String getRegistrationHeaderSnippet(){