Skip to content

Commit

Permalink
added login logout test bench #542
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Letter committed Dec 7, 2015
1 parent 12e68f7 commit 9f38436
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/slycat/web/server/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def abspath(path):
dispatcher.connect("put-upload-file-part", "/uploads/:uid/files/:fid/parts/:pid", slycat.web.server.handlers.put_upload_file_part, conditions={"method" : ["PUT"]})
dispatcher.connect("post-upload-finshed", "/uploads/:uid/finished", slycat.web.server.handlers.post_upload_finished, conditions={"method" : ["POST"]})
dispatcher.connect("delete-upload", "/uploads/:uid", slycat.web.server.handlers.delete_upload, conditions={"method" : ["DELETE"]})

dispatcher.connect("logout", "/logout", slycat.web.server.handlers.logout, conditions={"method" : ["DELETE"]})
dispatcher.connect("login", "/login/user/:un/password/:pw", slycat.web.server.handlers.login, conditions={"method" : ["POST"]})

def log_configuration(tree, indent=""):
for key, value in sorted(tree.items()):
Expand Down
5 changes: 5 additions & 0 deletions packages/slycat/web/server/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,11 @@ def delete_upload(uid):
slycat.web.server.upload.delete_session(uid)
cherrypy.response.status = "204 Upload session deleted."

@cherrypy.tools.json_in(on = True)
@cherrypy.tools.json_out(on = True)
def login(un, pw):
cherrypy.response.status = "404 no auth found" + un + pw

def logout():
# See if the client has a valid session.
if "slycatauth" in cherrypy.request.cookie:
Expand Down
46 changes: 44 additions & 2 deletions web-server/plugins/slycat-custom-auth/ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,61 @@ <h1 class="title">Login</h1>
<button class="btn btn-default" id="go">GO</button>
</div>
</form>
<div class="button-container">
<button class="btn btn-default" id="logout">LOGOUT</button>
</div>
</div>
</div>

<script type="text/javascript">
require(["slycat-web-client"], function(client)
require(["slycat-server-root", "jquery", "URI"], function(server_root, $, URI)
{
function login()
{
user_name = document.getElementById("Username").value
password = document.getElementById("Password").value
//TODO: add post call for username and password
window.alert("login " + user_name);
console.log("calling webservice with")
console.log("login " + user_name + " " + password);
console.log(server_root + "login/user/" + user_name + "/password/" + password)

$.ajax(
{
dataType: "json",
type: "POST",
url: URI(server_root + "login/user/" + user_name + "/password/" + password),
success: function(result)
{
console.log("success " + result);
},
error: function(request, status, reason_phrase)
{
console.log("error " + request + status + reason_phrase);
},
});

console.log("done")
}

function logout()
{
console.log("logging out");
$.ajax(
{
type: "DELETE",
url: server_root + "logout",
success: function()
{
console.log("success")
},
error: function(request, status, reason_phrase)
{
console.log("fail")
},
});
}
document.getElementById("go").addEventListener("click", login, false);
document.getElementById("logout").addEventListener("click", logout, false);
});
</script>
</div>

0 comments on commit 9f38436

Please sign in to comment.