You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by am...@apache.org on 2014/11/21 06:34:43 UTC
incubator-lens git commit: LENS-30 : Resolves login issues in UI
(Raju Bairishetti via amareshwari)
Repository: incubator-lens
Updated Branches:
refs/heads/master 6f0b0d9c5 -> 12cca8629
LENS-30 : Resolves login issues in UI (Raju Bairishetti via amareshwari)
Project: http://git-wip-us.apache.org/repos/asf/incubator-lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-lens/commit/12cca862
Tree: http://git-wip-us.apache.org/repos/asf/incubator-lens/tree/12cca862
Diff: http://git-wip-us.apache.org/repos/asf/incubator-lens/diff/12cca862
Branch: refs/heads/master
Commit: 12cca862945f864ba80d655854e0107d67d5dfb5
Parents: 6f0b0d9
Author: Amareshwari Sriramdasu <am...@inmobi.com>
Authored: Fri Nov 21 11:04:19 2014 +0530
Committer: Amareshwari Sriramdasu <am...@inmobi.com>
Committed: Fri Nov 21 11:04:19 2014 +0530
----------------------------------------------------------------------
.../lens/server/ui/SessionUIResource.java | 7 ++++---
lens-server/src/main/webapp/static/index.html | 6 ++++++
lens-server/src/main/webapp/static/js/index.js | 13 ++++++++++++
.../src/main/webapp/static/js/models/session.js | 22 +++++++++++++++++++-
lens-server/src/main/webapp/static/js/util.js | 10 +++++++++
5 files changed, 54 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/12cca862/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java b/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java
index 5c37b6d..29dc669 100644
--- a/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java
+++ b/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java
@@ -45,7 +45,7 @@ import java.util.UUID;
public class SessionUIResource {
/** The Constant LOG. */
- public static final Log LOG = LogFactory.getLog(SessionResource.class);
+ public static final Log LOG = LogFactory.getLog(SessionUIResource.class);
/** The open sessions. */
public static HashMap<UUID, LensSessionHandle> openSessions = new HashMap<UUID, LensSessionHandle>();
@@ -124,9 +124,10 @@ public class SessionUIResource {
* Session's public id of the session to be closed
* @return APIResult object indicating if the operation was successful (check result.getStatus())
*/
- @DELETE
+ @DELETE @Path("{publicId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
- public APIResult closeSession(@QueryParam("publicId") UUID publicId) {
+ public APIResult closeSession(@PathParam("publicId") UUID publicId) {
+ LOG.info("Closing session with id: " + publicId);
LensSessionHandle sessionHandle = openSessions.get(publicId);
checkSessionHandle(sessionHandle);
openSessions.remove(publicId);
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/12cca862/lens-server/src/main/webapp/static/index.html
----------------------------------------------------------------------
diff --git a/lens-server/src/main/webapp/static/index.html b/lens-server/src/main/webapp/static/index.html
index bebe26e..6b2bb8d 100644
--- a/lens-server/src/main/webapp/static/index.html
+++ b/lens-server/src/main/webapp/static/index.html
@@ -69,6 +69,7 @@
<li><a href="#query">Query</a></li>
<li><a href="#history">Query History</a></li>
</ul>
+ <button id="log-out" type="button">LogOut</button>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
@@ -186,6 +187,11 @@
#loginui {
margin-top: 50px;
}
+ button#log-out {
+ float: right;
+ margin-top: 10px;
+ margin-left: 0px;
+ }
.panel-body .CodeMirror {
height: auto;
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/12cca862/lens-server/src/main/webapp/static/js/index.js
----------------------------------------------------------------------
diff --git a/lens-server/src/main/webapp/static/js/index.js b/lens-server/src/main/webapp/static/js/index.js
index c07fe8f..7b2ff2f 100644
--- a/lens-server/src/main/webapp/static/js/index.js
+++ b/lens-server/src/main/webapp/static/js/index.js
@@ -396,6 +396,17 @@ $("#query-form").submit(function(event) {
}
});
+$("#log-out").click(function(event) {
+ event.preventDefault();
+ session.logOut(function() {
+ console.log("clearing cookies");
+ util.clearCookies();
+ $("#loginui").show();
+ $("#queryui, #historyui").hide();
+ $("#query-ui-content").hide();
+ });
+});
+
//Login form submit logic
$("#login-form").submit(function(event) {
event.preventDefault();
@@ -405,12 +416,14 @@ $("#login-form").submit(function(event) {
if (!email) {
$("#email").addClass("error");
+ alert("Enter your email address.");
return;
}
$("#email").removeClass("error");
if (!password) {
$("#password").addClass("error");
+ alert("Enter your password.");
return;
}
$("#password").removeClass("error");
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/12cca862/lens-server/src/main/webapp/static/js/models/session.js
----------------------------------------------------------------------
diff --git a/lens-server/src/main/webapp/static/js/models/session.js b/lens-server/src/main/webapp/static/js/models/session.js
index bf080d9..9d0e712 100644
--- a/lens-server/src/main/webapp/static/js/models/session.js
+++ b/lens-server/src/main/webapp/static/js/models/session.js
@@ -66,12 +66,15 @@ var Session = function() {
document.cookie="publicId=" + docCookies["publicId"];
document.cookie="secretId=" + docCookies["secretId"];
document.cookie="userName=" + docCookies["userName"];
- } else
+ } else {
+ alert("The email or password you entered is incorrect.");
console.log("Error authenticating user: " + data);
+ }
if (util.isFunction(callback))
callback();
},
error: function(jqXHR, textStatus, errorThrown) {
+ alert("The email or password you entered is incorrect.");
console.log("Error authenticating user: " + textStatus);
if (util.isFunction(callback))
callback();
@@ -215,6 +218,23 @@ var Session = function() {
return sessionHandle;
}
+ this.logOut = function(callback) {
+ var sessionVal = session.getSessionHandle()["publicId"];
+ $.ajax({
+ url: util.SESSION_URL + '/' + sessionVal,
+ type: 'DELETE',
+ contentType: "application/json; charset=utf-8",
+ processData: false,
+ success: function(data) {
+ console.log("successfully logged out");
+ callback();
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ console.log("Error in logout : " + textStatus);
+ }
+ });
+ };
+
/*
* Submits the query to the server
*/
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/12cca862/lens-server/src/main/webapp/static/js/util.js
----------------------------------------------------------------------
diff --git a/lens-server/src/main/webapp/static/js/util.js b/lens-server/src/main/webapp/static/js/util.js
index b4055ed..a123c87 100644
--- a/lens-server/src/main/webapp/static/js/util.js
+++ b/lens-server/src/main/webapp/static/js/util.js
@@ -51,4 +51,14 @@ var Util = function() {
return cookieObj;
};
+
+ this.clearCookies = function() {
+ var cookies = document.cookie.split(";");
+ for(var i = 0; i < cookies.length; i++) {
+ var eqPos = cookies[i].indexOf("=");
+ var name = eqPos > -1 ? cookies[i].substr(0, eqPos) : cookies[i];
+ // set the expires parameter to a passed date
+ document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
+ }
+ };
};