Commit 1e9dd387 authored by Alain Takoudjou's avatar Alain Takoudjou

Update Webrunner session management

parent f0bbe128
......@@ -11,7 +11,7 @@
width:702px;
}
#tabContaier textarea.slap{white-space: pre-wrap;word-wrap: break-word;overflow: hidden;color: #6F6F6F;width:430px; max-height:120px;
resize: none; height:18px;padding:3px;min-height:18px;}
resize: none; height:18px;padding:3px;min-height:18px;font-size: 13px;}
#tabContaier > ul{
overflow:hidden;
height:34px;
......
......@@ -39,6 +39,7 @@ th{
table.small th{padding: 4px;font-size: 16px;}
textarea {
width:762px;
font-family: 'Helvetica Neue',Tahoma,Helvetica,Arial,sans-serif;
}
body {
......@@ -650,8 +651,8 @@ a.lshare img{
.form{padding:10px; padding-left:20px;}
.form label{display:block; float:left; width:150px; padding-top:10px;}
.form input[type=text] ,.form input[type=password] {float:left; width:190px;margin:5px;}
.hiddendiv {display: none;white-space: pre-wrap;min-height: 18px;font-family: Arial, sans-serif;font-size: 13px;
padding:3px;word-wrap: break-word;width:430px; max-height:120px;}
.hiddendiv {display: none;white-space: pre-wrap;min-height: 18px;font-size: 13px;
padding:3px;word-wrap: break-word;width:430px; max-height:120px;font-family: 'Helvetica Neue',Tahoma,Helvetica,Arial,sans-serif;}
.list{background: url(../images/menu_dropdown.png) left center no-repeat; padding-left:10px;}
.slidebox{padding:10px; }
.alert_message{ background: url(../images/alert.png) center no-repeat; height: 26px;}
......
$(document).ready( function() {
var send = false;
var cloneRequest;
$('#fileTree').fileTree({ root: $("input#workdir").val(), script: $SCRIPT_ROOT + '/readFolder', folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false }, function(file) {
$('#fileTree').fileTree({ root: $("input#workdir").val(), script: $SCRIPT_ROOT + '/readFolder', folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false }, function(file) {
selectFile(file);
});
configRadio();
......@@ -22,12 +22,12 @@ $(document).ready( function() {
$("#clone").append("Clone");
send = false;
return;
}
}
var repo_url = $("input#repo").val();
var email = "";
var name = ""
/* /^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/ */
if($("input#repo").val() == "" || !repo_url.match(/^[\w\d\.\/:~@_-]+$/)){
if($("input#repo").val() == "" || !repo_url.match(/^[\w\d\.\/:~@_-]+$/)){
$("#error").Popup("Invalid url for the repository", {type:'alert', duration:3000});
return false;
}
......@@ -35,7 +35,7 @@ $(document).ready( function() {
$("#error").Popup("Invalid project name", {type:'alert', duration:3000});
return false;
}
if($("input#user").val() != "" && $("input#user").val() != "Enter your name..."){
if($("input#user").val() !== ""){
name = $("input#user").val();
}
if($("input#email").val() != "" && $("input#email").val() != "Enter your email adress..."){
......@@ -86,7 +86,7 @@ $(document).ready( function() {
$("#error").Popup("Your repository is cloned!", {type:'confirm', duration:3000});
$("input#repo").val("Enter the url of your repository...");
$("input#name").val("Enter the project name...");
$('#fileTree').fileTree({ root: $("input#workdir").val(), script: $SCRIPT_ROOT + '/readFolder', folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false }, function(file) {
$('#fileTree').fileTree({ root: $("input#workdir").val(), script: $SCRIPT_ROOT + '/readFolder', folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false }, function(file) {
selectFile(file);
});
}
......@@ -102,10 +102,10 @@ $(document).ready( function() {
return false;
});
function configRadio(){
$("#modelist li").each(function(index) {
$("#modelist li").each(function(index) {
var boxselector = "#box" + index;
if($(this).hasClass('checked')){
$(this).removeClass('checked');
$(this).removeClass('checked');
$(boxselector).slideUp("normal");
}
if($(this).find("input:radio").is(':checked')){
......@@ -119,7 +119,7 @@ $(document).ready( function() {
}
});
}
function selectFile(file){
//nothing
return;
......
......@@ -41,6 +41,14 @@ def html_escape(text):
return "".join(html_escape_table.get(c,c) for c in text)
def checkLogin(config, login, pwd):
user = getSession(config)
salt = "runner81" #to be changed
current_pwd = hashlib.md5( salt + pwd ).hexdigest()
if current_pwd == user[1]:
return user
return False
def getSession(config):
user_path = os.path.join(config['runner_workdir'], '.users')
user = ""
if os.path.exists(user_path):
......@@ -52,11 +60,29 @@ def checkLogin(config, login, pwd):
user = open(user_path, 'r').read().split(';')
else:
return False
salt = "runner81" #to be changed
current_pwd = hashlib.md5( salt + pwd ).hexdigest()
if current_pwd == user[1]:
return user
return False
return user
def saveSession(config, session, account):
user = os.path.join(config['runner_workdir'], '.users')
try:
if account[1]:
salt = "runner81" #to be changed
account[1] = hashlib.md5(salt + account[1]).hexdigest()
else:
account[1] = session['account'][1]
#backup previous data
open(user+'.back', 'w').write(';'.join(session['account']))
#save new account data
open(user, 'w').write((';'.join(account)).encode("utf-8"))
session['account'] = account
return True
except Exception, e:
try:
os.remove(user)
os.rename(user+'.back', user)
except:
pass
return str(e)
def updateProxy(config):
if not os.path.exists(config['instance_root']):
......
......@@ -19,8 +19,7 @@ def before_request():
return redirect(url_for('login'))
if session.has_key('account') and session['account']:
session['title'] = getProjectTitle(app.config)
session['account'] = open(os.path.join(app.config['runner_workdir'], '.users'),
'r').read().split(';')
session['account'] = getSession(app.config)
# general views
@app.route('/')
......@@ -46,7 +45,9 @@ def logout():
@app.route('/configRepo')
def configRepo():
public_key = open(app.config['public_key'], 'r').read()
return render_template('cloneRepository.html', workDir='workspace', public_key=public_key)
return render_template('cloneRepository.html', workDir='workspace',
public_key=public_key, name=session['account'][3].decode('utf-8'),
email=session['account'][2])
@app.route("/doLogin", methods=['POST'])
def doLogin():
......@@ -450,23 +451,14 @@ def getParameterXml(request):
@app.route("/updateAccount", methods=['POST'])
def updateAccount():
account = session['account'][:] #copy session data
account = []
user = os.path.join(app.config['runner_workdir'], '.users')
try:
if request.form['username'].strip():
account[0] = request.form['username'].strip()
account[2] = request.form['email'].strip()
account[3] = request.form['name'].strip()
if request.form['password'].strip():
salt = "runner81" #to be changed
account[1] = hashlib.md5(salt + request.form['password'].strip()).hexdigest()
#backup previous data
open(user+'.back', 'w').write(';'.join(session['account']))
#save new account data
open(user, 'w').write((';'.join(account)).encode("utf-8"))
session['account'] = account
return jsonify(code=1, result="")
except Exception, e:
os.remove(user)
os.rename(user+'.back', user)
return jsonify(code=0, result=str(e))
\ No newline at end of file
account.append(request.form['username'].strip())
account.append(request.form['password'].strip())
account.append(request.form['email'].strip())
account.append(request.form['name'].strip())
result = saveSession(app.config, session, account)
if type(result) == type(""):
return jsonify(code=0, result=result)
else:
return jsonify(code=1, result="")
\ No newline at end of file
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