Skip to content

Commit

Permalink
updating what to do with location on login #560
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Letter committed Jan 22, 2016
1 parent 0083860 commit 1b19057
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/slycat/web/server/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import functools
from cherrypy._cpcompat import base64_decode
import datetime
import urlparse

def css_bundle():
with css_bundle._lock:
Expand Down Expand Up @@ -692,12 +693,18 @@ def login():
cherrypy.log.error("decoding username and password")
user_name = base64_decode(cherrypy.request.json["user_name"])
password = base64_decode(cherrypy.request.json["password"])
location = cherrypy.request.json["location"]
except:
cherrypy.log.error("username and password could not be decoded")
slycat.email.send_error("slycat-standard-authentication.py authenticate", "cherrypy.HTTPError 400")
raise cherrypy.HTTPError(400)
realm = None

if urlparse.parse_qs(urlparse.urlparse(location).query)['from']:
unparsed_url = urlparse.parse_qs(urlparse.urlparse(location).query)['from']
response_url = urlparse.urlparse(unparsed_url)
# if response_url.__contains__()

# Get the client ip, which might be forwarded by a proxy.
remote_ip = cherrypy.request.headers.get("x-forwarded-for") if "x-forwarded-for" in cherrypy.request.headers else cherrypy.request.rem

Expand Down Expand Up @@ -732,11 +739,11 @@ def login():
cherrypy.response.cookie["slycatauth"]["secure"] = 1
cherrypy.response.cookie["slycatauth"]["httponly"] = 1
cherrypy.response.status = "200 OK"
cherrypy.request.login = user_name#TODO:might be able to delete this
cherrypy.request.login = user_name
else:
cherrypy.log.error("user %s at %s failed authentication" % (user_name, remote_ip))
cherrypy.response.status = "404 no auth found!!!"
return {'success': success}
return {'success': success, 'location':location}


login.password_check = None
Expand Down

0 comments on commit 1b19057

Please sign in to comment.