From 0b9e14ddb345dc6c3ce0102b9fe3121995b843f2 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Thu, 2 Jul 2015 17:09:21 +0530 Subject: [PATCH] login redirection resolved --- .../repository/jaggeryapps/iot/api/user-api.jag | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iot/api/user-api.jag b/modules/distribution/src/repository/jaggeryapps/iot/api/user-api.jag index e8f1aa79..6658fda0 100644 --- a/modules/distribution/src/repository/jaggeryapps/iot/api/user-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iot/api/user-api.jag @@ -33,6 +33,7 @@ if (uriMatcher.match("/{context}/api/user/login/")) { var username = request.getParameter("username"); var password = request.getParameter("password"); + var redirect = request.getParameter("redirect"); try { userModule.login(username, password, function (user) { @@ -40,13 +41,25 @@ if (uriMatcher.match("/{context}/api/user/login/")) { if (log.isDebugEnabled()) { log.debug("User Logged In : " + user); } - response.sendRedirect(constants.WEB_APP_CONTEXT); + if(redirect==null){ + response.sendRedirect(constants.WEB_APP_CONTEXT); + }else{ + + result=200; + } }, function () { - response.sendRedirect(dcProps.appContext + "login?#auth-failed"); + + if(redirect==null){ + response.sendRedirect(dcProps.appContext + "login?#auth-failed"); + }else{ + + result=401; + } }); } catch (e) { log.error("Exception occurred while a user tried to login to DC", e); response.sendRedirect(dcProps.appContext + "login?#error"); + } } else if (uriMatcher.match("/{context}/api/user/logout/")) {