Subversion Repositories SmartDukaan

Rev

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

Rev 25243 Rev 25275
Line 144... Line 144...
144
	public String home() {
144
	public String home() {
145
		return "redirect:/login";
145
		return "redirect:/login";
146
	}
146
	}
147
 
147
 
148
	@RequestMapping(value = "/mobileapp", method = RequestMethod.GET)
148
	@RequestMapping(value = "/mobileapp", method = RequestMethod.GET)
149
	public String mobileApp(HttpServletRequest request, Model model) throws Exception {
149
	public String mobileApp(HttpServletRequest request, Model model, @RequestParam(defaultValue = "") String emailId)
-
 
150
			throws Exception {
150
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
151
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
151
		if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
152
		if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
-
 
153
			if (emailId.equals("")) {
152
			model.addAttribute("authToken", getToken(fofoDetails.getEmailId()));
154
				model.addAttribute("authToken", getToken(fofoDetails.getEmailId()));
-
 
155
			} else {
-
 
156
				model.addAttribute("authToken", getToken(emailId));
-
 
157
			}
153
		}
158
		}
154
		return "mobileapp";
159
		return "mobileapp";
155
	}
160
	}
156
 
161
 
157
	private String getToken(String emailId) throws Exception {
162
	private String getToken(String emailId) throws Exception {
Line 221... Line 226...
221
				}
226
				}
222
 
227
 
223
			} else {
228
			} else {
224
				try {
229
				try {
225
					emailId = googleTokenUtil.getEmailId(token);
230
					emailId = googleTokenUtil.getEmailId(token);
226
				} catch(Exception e) {
231
				} catch (Exception e) {
227
					//in case we cannot connect to google server.
232
					// in case we cannot connect to google server.
228
					emailId = emailIdOrMobileNumber;
233
					emailId = emailIdOrMobileNumber;
229
				}
234
				}
230
				if (ProfitMandiConstants.BLOCKED_EMAILS.contains(emailId)) {
235
				if (ProfitMandiConstants.BLOCKED_EMAILS.contains(emailId)) {
231
				}
236
				}
232
			}
237
			}
Line 275... Line 280...
275
			Role roleFofo = roleRepository.selectByName(RoleType.FOFO.toString());
280
			Role roleFofo = roleRepository.selectByName(RoleType.FOFO.toString());
276
			Role roleFofoAdmin = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
281
			Role roleFofoAdmin = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
277
 
282
 
278
			if (fofoDetails.getRoleIds().contains(roleFofo.getId())) {
283
			if (fofoDetails.getRoleIds().contains(roleFofo.getId())) {
279
				redirectUrl = "/dashboard";
284
				redirectUrl = "/dashboard";
280
				if(fofoDetails.getRoleIds().contains(roleFofo.getId())) {
285
				if (fofoDetails.getRoleIds().contains(roleFofo.getId())) {
281
					
286
 
282
				}
287
				}
283
			} else {
288
			} else {
284
				redirectUrl = "/login";
289
				redirectUrl = "/login";
285
			}
290
			}
286
 
291
 
Line 292... Line 297...
292
				model.addAttribute("response", mvcResponseSender.createResponseString("RTLR_OK_1002", true,
297
				model.addAttribute("response", mvcResponseSender.createResponseString("RTLR_OK_1002", true,
293
						request.getContextPath() + redirectUrl, name));
298
						request.getContextPath() + redirectUrl, name));
294
			} else {
299
			} else {
295
				LOGGER.error("Requested token email_id is not valid, please try to login");
300
				LOGGER.error("Requested token email_id is not valid, please try to login");
296
				/**
301
				/**
297
				 * TODO:Amit
-
 
298
				 * This redirect should be handle.
302
				 * TODO:Amit This redirect should be handle.
299
				 */
303
				 */
300
				throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, fofoDetails.getEmailId(),
304
				throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, fofoDetails.getEmailId(),
301
						"RTLR_1000");
305
						"RTLR_1000");
302
			}
306
			}
303
			return "response";
307
			return "response";