Commit d07b2804 authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

Platform/Login: fixed direct linking for normal login

fixes
parent de8adc66
......@@ -75,19 +75,6 @@ class RootController(AbstractController):
logger.info("Mounting controller '%s'" % os.path.join(os.sep, mountpoint))
setattr(self.extensions, mountpoint, controller)
def requested_path(self, delete=True):
path = ""
if "requested_path" in cherrypy.session.keys():
path += cherrypy.session["requested_path"]
if delete:
del cherrypy.session["requested_path"]
if "query_string" in cherrypy.session.keys():
if cherrypy.session["query_string"]:
path += "?" + cherrypy.session["query_string"]
if delete:
del cherrypy.session["query_string"]
return path
def get_preferences(self, db, user_id, parse_json=False):
preferences = {}
preferences["vispa_preferences"] = VispaPreference.get_data_by_user_id(db, user_id)
......@@ -185,9 +172,12 @@ class RootController(AbstractController):
@cherrypy.tools.render(template="sites/login.mako")
@cherrypy.tools.method(accept="GET")
def login(self, *args, **kwargs):
path = self.requested_path()
path = vispa.url.dynamic("?" + cherrypy.request.query_string)
db = cherrypy.request.db
if "user_id" in cherrypy.session:
raise cherrypy.HTTPRedirect(path)
login = cherrypy.request.login
if login and vispa.config("user", "remote.enabled", False):
user = User.get_by_name(db, login)
......@@ -218,7 +208,6 @@ class RootController(AbstractController):
disclaimer_text = vispa.config("web", "text.disclaimer", "")
use_forgot = vispa.config("web", "forgot.use", False)
return {
"requested_path" : path,
"welcome_phrase" : welcome_phrase,
"login_text" : login_text,
"registration_text": registration_text,
......@@ -232,17 +221,16 @@ class RootController(AbstractController):
@cherrypy.tools.user(on=False)
@cherrypy.tools.method(accept="GET")
def guest_login(self, *args, **kwargs):
# return an error when guest logins are disabled
if vispa.config("web", "enable_guest_login", False) is False:
raise cherrypy.HTTPError(403, "Guest login not allowed!")
req = cherrypy.request
path = vispa.url.dynamic("?" + req.query_string)
path = vispa.url.dynamic("?" + cherrypy.request.query_string)
# redirect when the user is already logged in
if "user_id" in cherrypy.session:
raise cherrypy.HTTPRedirect(path)
# return an error when guest logins are disabled
if vispa.config("web", "enable_guest_login", False) is False:
raise cherrypy.HTTPError(403, "Guest login not allowed!")
# actual guest login
user, password = User.guest_login(req.db)
......
......@@ -77,7 +77,7 @@ define([
var d = new Date();
d.setTime(d.getTime() + 60e3);
$.cookie("tmpPass", pass, { expires: d });
window.location.href = self.url.dynamic(self.config.requestedPath);
window.location.href = self.url.dynamic(location.search);
}
});
......
......@@ -14,10 +14,9 @@
// use template variables to create the vispa config
var vispaConfig = {
url: {
dynamicBase: "${base_dynamic}",
staticBase : "${base_static}"
dynamicBase: "${base_dynamic}",
staticBase : "${base_static}"
},
requestedPath: "${requested_path}",
useForgot : ${"true" if use_forgot else "false"}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment