Commit 146164ad authored by Marcel's avatar Marcel
Browse files

Update vispa.ini.sample. Connect password recovery form.

parent 5fa5bc21
......@@ -6,9 +6,11 @@ sqlalchemy.url: sqlite:///var/db/vispa.db
script_location = alembic
[web]
#welcome_text = "Welcome to VISPA"
#login_text = "Information for Login "
#registration_text = "Information for Registration"
welcome_text = <center>Welcome to VISPA!</center>
#login_text = Information for Login
#registration_text = Information for Registration
forgot_text = A mail with further instructions will be sent to your mail account!
use_forgot = False
[executable]
# pxlrun command options, call of executable will be:
......
......@@ -30,10 +30,6 @@ body {
margin-bottom: 20px;
}
.content-bottom {
}
#accordion > div {
overflow: hidden;
}
......
......@@ -4,6 +4,7 @@ var Vispa = function() {
config = {
requestedPath: '/',
view: {},
messenger: {},
url: {}
},
......@@ -18,7 +19,7 @@ var Vispa = function() {
updateConfig(_config);
messenger.startup(config.messenger);
urlHandler.startup(config.url);
view.startup();
view.startup(config.view);
},
updateConfig = function(_config) {
......@@ -45,7 +46,7 @@ var Vispa = function() {
});
$.when(promise).then(function(response) {
if(!response.success) {
$.Topic('msg.error').publish(response.message);
$.Topic('msg.error').publish(response.msg);
} else {
$.Helpers.redirect(urlHandler.static(config.requestedPath));
}
......@@ -92,7 +93,7 @@ var Vispa = function() {
});
$.when(promise).then(function(response) {
if(!response.success) {
$.Topic('msg.error').publish(response.message);
$.Topic('msg.error').publish(response.msg);
} else {
$.Helpers.redirect(urlHandler.static('/'));
}
......@@ -108,7 +109,22 @@ var Vispa = function() {
},
forgot = function() {
$.Topic('msg.info').publish('TODO');
var user = $('#forgot-name').val();
if(!user) {
$('#forgot-name').focus();
return self;
}
var promise = $.ajax({
type: 'POST',
url: urlHandler.static('/ajax/user/forgot'),
data: {username: user}
});
$.when(promise).then(function(response) {
$.Topic('msg.info').publish(response.msg);
$('#accordion').accordion('option', 'active', 0);
}).fail(function(request, status, msg) {
$.Topic('msg.error').publish($.Helpers.strFormat('{0}: {1}', request.status, msg));
});
return self;
};
......
......@@ -2,12 +2,22 @@ var View = function() {
var self,
startup = function() {
config = {
useForgot: false
},
startup = function(_config) {
updateConfig(_config);
setupMarkup();
$('#login-name').focus();
hideOverlay();
},
updateConfig = function(_config) {
$.extend(true, config, _config);
return self;
},
setupMarkup = function() {
// accordion
$('#accordion').accordion({
......@@ -69,6 +79,11 @@ var View = function() {
$('#forgot-name').keypress(function(event) {
next(event, vispa.forgot);
});
// hide the 'forgot password' container?
if(!config.useForgot) {
var selectors = '#login-forgot, #forgot-container, #forgot-container-header';
$(selectors).hide();
}
},
hideOverlay = function(fx) {
......
......@@ -16,15 +16,9 @@
<%
jquery_scripts = ["jquery.min.js",
"ui/jquery.ui.min.js",
"mobile/jquery.mobile.min.js",
"jgestures/jquery.jgestures.min.js",
"hotkeys/jquery.hotkeys.min.js",
"qtip/jquery.qtip.min.js",
"ui/jquery.ui.touch-punch.min.js",
"topics/jquery.topics.min.js",
"polling/jquery.polling.min.js",
"shortcuts/jquery.shortcuts.min.js",
"history/jquery.history.min.js",
"sha256/jquery.sha256.min.js"]
base_scripts = ["helpers.js",
"messenger.js",
......@@ -60,6 +54,9 @@
$(function() {
var config = {
requestedPath: '${requested_path}',
view: {
useForgot: ${"true" if use_forgot else "false"},
},
url: {
staticBase: '${base_static}',
dynamicBase: '${base_dynamic}'
......@@ -74,80 +71,80 @@ $(function() {
<div id='startup-overlay' class='startup-overlay'></div>
<div id="content-outer" class="content-outer">
<div id="content-logo" class="content-logo">
<img src='${url.static("img/vispa/Vispa2.0Logo_300.png")}' />
<div class='content-outer'>
<div class='content-logo'>
<img src='${url.static('img/vispa/Vispa2.0Logo_300.png')}' />
</div>
<div id="content-top" class="content-top">
${welcome_text or ""}
<div class='content-top'>
${welcome_text or ''}
</div>
<div id="content-bottom" class="content-bottom">
<div id="accordion">
<div>
<div id='accordion'>
<h3>Login</h3>
<div>
${login_text + "<br />" if login_text else ""}
<table class="table">
${login_text + '<br />' if login_text else ''}
<table class='table'>
<tr>
<td>Username or mail address:</td>
<td><input type="text" id="login-name" class="input" /></td>
<td><input type='text' id='login-name' class='input' /></td>
<td></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" id="login-password" class="input" /></td>
<td><input type='password' id='login-password' class='input' /></td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<span id="login-submit">Login</span>
<span id='login-submit'>Login</span>
</td>
<td>
<span id="login-forgot">Forgot Password</span>
<span id='login-forgot'>Forgot Password</span>
</td>
</tr>
</table>
</div>
<h3>Register</h3>
<div>
${registration_text + "<br />" if registration_text else ""}
<table class="table">
${registration_text + '<br />' if registration_text else ''}
<table class='table'>
<tr>
<td>Username:</td>
<td><input type="text" id="register-name" class="input" /></td>
<td><input type='text' id='register-name' class='input' /></td>
</tr>
<tr>
<td>Mail address:</td>
<td><input type="text" id="register-mail-1" class="input" /></td>
<td><input type='text' id='register-mail-1' class='input' /></td>
</tr>
<tr>
<td>Confirm mail address:</td>
<td><input type="text" id="register-mail-2" class="input" /></td>
<td><input type='text' id='register-mail-2' class='input' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" id="register-password" class="input" /></td>
<td><input type='password' id='register-password' class='input' /></td>
</tr>
<tr>
<td></td>
<td>
<span id="register-submit">Register</span>
<span id='register-submit'>Register</span>
</td>
</tr>
</table>
</div>
<h3>Forgot password</h3>
<div>
${forgot_text + "<br /><br />" if forgot_text else ""}
<table class="table">
<h3 id='forgot-container-header'>Forgot password</h3>
<div id='forgot-container'>
${forgot_text + '<br /><br />' if forgot_text else ''}
<table class='table'>
<tr>
<td>Username or mail address:</td>
<td><input type="text" id="forgot-name" class="input" /></td>
<td><input type='text' id='forgot-name' class='input' /></td>
</tr>
<tr>
<td></td>
<td>
<span id="forgot-submit">Send</span>
<span id='forgot-submit'>Send</span>
</td>
</tr>
</table>
......
......@@ -10,7 +10,13 @@ config.read('conf/vispa.ini')
def get2(section, option, default=""):
if config.has_section(section):
if config.has_option(section, option):
return config.get(section, option)
value = config.get(section, option)
# try to cast to boolean
if value == "True":
return True
if value == "False":
return False
return value
return default
config.get2 = get2
......
......@@ -63,7 +63,7 @@ class UserController:
cherrypy.session['user_name'] = username
return {'success': True}
else:
return {'success': False, 'message': user}
return {'success': False, 'msg': user}
@cherrypy.expose
......@@ -82,13 +82,13 @@ class UserController:
call(cmd)
return {'success': True}
else:
return {'success': False, 'message': user}
return {'success': False, 'msg': user}
@cherrypy.expose
@cherrypy.tools.json_out()
def forgot(self, user, *args, **kwargs):
link = User.forgot_password(cherrypy.request.db, user)
return {"link": str(link)}
def forgot(self, username):
User.forgot_password(cherrypy.request.db, username)
return {"msg": "Further instructions have been sent to your mail address!"}
@cherrypy.expose
@cherrypy.tools.json_out()
......@@ -101,11 +101,4 @@ class UserController:
if User.is_active(cherrypy.request.db, user.id):
cherrypy.session['user_id'] = unicode(user.id)
cherrypy.session['user_name'] = user.name
return {"success": True}
@cherrypy.expose
@cherrypy.tools.user()
@cherrypy.tools.json_out()
def checkUniqueness(self, *args, **kwargs):
#TODO
return {'success': True}
return {"success": True}
\ No newline at end of file
......@@ -28,33 +28,6 @@ class PlatformController(object):
self.extensions = StaticController("vispa/extensions")
self.bus = BusController()
@cherrypy.expose
@cherrypy.tools.user()
@cherrypy.tools.render(template="index.html")
def index_old(self, *args, **kwargs):
# is there a query string?
if len(kwargs.keys()) > 0:
cherrypy.session["index_querystring"] = kwargs
raise cherrypy.HTTPRedirect(vispa.url.base_static)
username = cherrypy.session['user_name']
# setup the user folder
#self._platform.vfs.setupUserFolder(str(username))
# stats
AccessStats.click(cherrypy.request.db, browser.client_ip(), browser.client_agent())
data = {'commonJs': self._platform.common_js, 'commonCss': self._platform.common_css,
'username': username}
# append the query string to the returned data
if "index_querystring" in cherrypy.session.keys():
qs = []
for key in cherrypy.session["index_querystring"].keys():
qs.append("%s=%s" % (key, cherrypy.session["index_querystring"][key]))
del cherrypy.session["index_querystring"]
data.update({"querystring": "&".join(qs)})
return data
@cherrypy.expose
@cherrypy.tools.user()
@cherrypy.tools.allow(methods=["GET"])
......@@ -71,21 +44,23 @@ class PlatformController(object):
@cherrypy.tools.allow(methods=["GET"])
@cherrypy.tools.render(template="sites/login.html")
def login(self, *args, **kwargs):
welcome_text = vispa.config.get2("web", "welcome_text")
login_text = vispa.config.get2("web", "login_text")
registration_text = vispa.config.get2("web", "registration_text")
forgot_text = vispa.config.get2("web", "forgot_text")
path = u""
if "requested_path" in cherrypy.session.keys():
path += cherrypy.session["requested_path"]
if "query_string" in cherrypy.session.keys():
if cherrypy.session["query_string"] != "":
path += "?" + cherrypy.session["query_string"]
welcome_text = vispa.config.get2("web", "welcome_text")
login_text = vispa.config.get2("web", "login_text")
registration_text = vispa.config.get2("web", "registration_text")
forgot_text = vispa.config.get2("web", "forgot_text")
use_forgot = vispa.config.get2("web", "use_forgot", False)
return {"requested_path": path,
"welcome_text": welcome_text,
"login_text": login_text,
"registration_text": registration_text,
"forgot_text": forgot_text}
"forgot_text": forgot_text,
"use_forgot": use_forgot}
@cherrypy.expose
@cherrypy.tools.user()
......
Supports Markdown
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