X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=validation.git;a=blobdiff_plain;f=ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fakraino%2Fvalidation%2Fui%2Flogin%2FLoginStrategyImpl.java;fp=ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fakraino%2Fvalidation%2Fui%2Flogin%2FLoginStrategyImpl.java;h=bebc35a61a37c49701367712d6977f73d7ee58c4;hp=ea144838d48e4ef129f94a40100eb2043dfe7b2a;hb=19e7a87af0e8b17a418497b41c8b8c98708cd01f;hpb=c80adf55823ca40d1b68e4a9186a615c9f9a2952 diff --git a/ui/src/main/java/org/akraino/validation/ui/login/LoginStrategyImpl.java b/ui/src/main/java/org/akraino/validation/ui/login/LoginStrategyImpl.java index ea14483..bebc35a 100644 --- a/ui/src/main/java/org/akraino/validation/ui/login/LoginStrategyImpl.java +++ b/ui/src/main/java/org/akraino/validation/ui/login/LoginStrategyImpl.java @@ -65,6 +65,7 @@ public class LoginStrategyImpl extends LoginStrategy { LoginBean commandBean = new LoginBean(); String loginId = request.getParameter("loginId"); String password = request.getParameter("password"); + String redirectUrl = request.getParameter("redirectUrl"); commandBean.setLoginId(loginId); commandBean.setLoginPwd(password); commandBean.setUserid(loginId); @@ -77,15 +78,25 @@ public class LoginStrategyImpl extends LoginStrategy { : "login.error.external.invalid"; Map model = new HashMap<>(); model.put("error", loginErrorMessage); - return new ModelAndView("login_external", "model", model); + if (redirectUrl == null || redirectUrl.equals("")) { + return new ModelAndView("login_external", "model", model); + } else { + return new ModelAndView( + "redirect:login_external.htm?redirectUrl=" + request.getParameter("redirectUrl")); + } } else { // store the currently logged in user's information in the session UserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), commandBean.getBusinessDirectMenu(), SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_BACKDOOR), roleFunctionList); initateSessionMgtHandler(request); - // user has been authenticated, now take them to the welcome page - return new ModelAndView("redirect:welcome.htm"); + // user has been authenticated, now take them to the welcome or redirection page + if (redirectUrl == null || redirectUrl.equals("")) { + return new ModelAndView("redirect:welcome.htm"); + } else { + return new ModelAndView("redirect:" + + redirectUrl.substring(redirectUrl.lastIndexOf("/bluvalui/") + 10, redirectUrl.length())); + } } } @@ -97,6 +108,7 @@ public class LoginStrategyImpl extends LoginStrategy { LoginBean commandBean = new LoginBean(); String loginId = request.getParameter("loginId"); String password = request.getParameter("password"); + String redirectUrl = request.getParameter("redirectUrl"); commandBean.setLoginId(loginId); commandBean.setLoginPwd(password); commandBean.setUserid(loginId); @@ -113,15 +125,25 @@ public class LoginStrategyImpl extends LoginStrategy { : "login.error.external.invalid"; Map model = new HashMap<>(); model.put("error", loginErrorMessage); - return new ModelAndView("login_external", "model", model); + if (redirectUrl == null || redirectUrl.equals("")) { + return new ModelAndView("login_external", "model", model); + } else { + return new ModelAndView( + "redirect:login_external.htm?redirectUrl=" + request.getParameter("redirectUrl")); + } } else { // store the currently logged in user's information in the session UserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), commandBean.getBusinessDirectMenu(), SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_BACKDOOR), roleFunctionList); initateSessionMgtHandler(request); - // user has been authenticated, now take them to the welcome page - return new ModelAndView("redirect:welcome"); + // user has been authenticated, now take them to the welcome or redirection page + if (redirectUrl == null || redirectUrl.equals("")) { + return new ModelAndView("redirect:welcome.htm"); + } else { + return new ModelAndView("redirect:" + + redirectUrl.substring(redirectUrl.lastIndexOf("/bluvalui/") + 10, redirectUrl.length())); + } } } catch (CipherUtilException e) { LOGGER.error(EELFLoggerDelegate.errorLogger, "Error in Cipher." + UserUtils.getStackTrace(e)); @@ -130,8 +152,13 @@ public class LoginStrategyImpl extends LoginStrategy { commandBean.getBusinessDirectMenu(), SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_BACKDOOR), roleFunctionList); initateSessionMgtHandler(request); - // user has been authenticated, now take them to the welcome page - return new ModelAndView("redirect:welcome"); + // user has been authenticated, now take them to the welcome or redirection page + if (redirectUrl == null || redirectUrl.equals("")) { + return new ModelAndView("redirect:welcome.htm"); + } else { + return new ModelAndView("redirect:" + + redirectUrl.substring(redirectUrl.lastIndexOf("/bluvalui/") + 10, redirectUrl.length())); + } } }