stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pradee...@apache.org
Subject git commit: usename/password login, authenticate and get roles. happy path working
Date Mon, 03 Feb 2014 09:49:50 GMT
Updated Branches:
  refs/heads/master dac3417d7 -> 9e1f7145a


usename/password login, authenticate and get roles. happy path working


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/9e1f7145
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/9e1f7145
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/9e1f7145

Branch: refs/heads/master
Commit: 9e1f7145a3ba638bd487e212516cec53435ee735
Parents: dac3417
Author: Pradeep Fernando <pradeepfn@gmail.com>
Authored: Mon Feb 3 15:19:31 2014 +0530
Committer: Pradeep Fernando <pradeepfn@gmail.com>
Committed: Mon Feb 3 15:19:31 2014 +0530

----------------------------------------------------------------------
 .../console/controllers/loginSubmit.jag         | 24 ++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/9e1f7145/components/org.apache.stratos.manager.console/console/controllers/loginSubmit.jag
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/controllers/loginSubmit.jag
b/components/org.apache.stratos.manager.console/console/controllers/loginSubmit.jag
index 4cd11c3..4a69121 100644
--- a/components/org.apache.stratos.manager.console/console/controllers/loginSubmit.jag
+++ b/components/org.apache.stratos.manager.console/console/controllers/loginSubmit.jag
@@ -2,24 +2,30 @@
 (function(){
     var log = new Log("controller.credentialSubmit");
     var utils = require('/util/utility.jag');
+    var carbon = require('carbon');
+    var server = new carbon.server.Server();
+    //TODO: handle the angry path...
     var username = request.getParameter("username").trim();
     var password = request.getParameter("password"); // not trimming the password
-    log.info("username/password submitted");
-    log.info(username);
-    log.info(password);
     //authenticate with carbon usr-store
-
-
+    var auth = server.authenticate(username, password);
+    var userObject = carbon.server.tenantUser(username);
+    var um = new carbon.user.UserManager({}, userObject.tenantId);
+    var user = um.getUser('admin');
+    var roles = user.getRoles();
+    //storing in session
+    session.put("TENANT_DOMAIN",userObject.domain);
+    session.put("ROLE_ARRAY",roles);
     //call the authentication rest-endpoint and get the JSESSION_ID
-    var response =  utils.consoleAppUtil.getSessionCookie(username,password);
-    log.info(response.data.Success.sessionId);
+    var result =  utils.consoleAppUtil.getSessionCookie(username,password);
+    log.info(result.data.Success.sessionId);
     //TODO: handle the error scenario
     //save the JSESSION_ID in current console.session.
-    var jSessionId = response.data.Success.sessionId;
+    var jSessionId = result.data.Success.sessionId;
     session.put("JSESSIONID",jSessionId);
     require('console').server.current(session,username);
     //redirect
-    response.sendRedirect(request.getContextPath());
+    response.sendRedirect(request.getContextPath()+'/index.jag');
 
 }());
 %>
\ No newline at end of file


Mime
View raw message