Commit 570c4f1d authored by Alain Takoudjou's avatar Alain Takoudjou

Add missing changes for utf-8 encoding

parent 652bc606
...@@ -42,7 +42,7 @@ textarea { ...@@ -42,7 +42,7 @@ textarea {
} }
body { body {
background: url("../images/1307251316-background-stripes.gif") repeat #9C9C9C; background: #2281C1;/*url("../images/1307251316-background-stripes.gif") repeat #9C9C9C;*/
font-family: 'Helvetica Neue',Tahoma,Helvetica,Arial,sans-serif; font-family: 'Helvetica Neue',Tahoma,Helvetica,Arial,sans-serif;
color: #000000; color: #000000;
font-size: 13px; font-size: 13px;
......
...@@ -116,7 +116,8 @@ ...@@ -116,7 +116,8 @@
</table> </table>
</div> </div>
</div> </div>
<div style="margin-left:10px;"> <br/>
<div>
<a id="updateParameters" class="lshare simple no-right-border" style="float:left">Update Values</a> <a id="updateParameters" class="lshare simple no-right-border" style="float:left">Update Values</a>
<a href="#" id="xmlview" class="lshare simple" style="float:left">Load XML</a> <a href="#" id="xmlview" class="lshare simple" style="float:left">Load XML</a>
</div> </div>
......
...@@ -41,9 +41,17 @@ def html_escape(text): ...@@ -41,9 +41,17 @@ def html_escape(text):
return "".join(html_escape_table.get(c,c) for c in text) return "".join(html_escape_table.get(c,c) for c in text)
def checkLogin(config, login, pwd): def checkLogin(config, login, pwd):
if not os.path.exists(os.path.join(config['runner_workdir'], '.users')): user_path = os.path.join(config['runner_workdir'], '.users')
user = ""
if os.path.exists(user_path):
user = open(user_path, 'r').read().split(';')
if type(user) == type(""):
#Error: try to restore data from backup
if os.path.exists(user_path+'.back'):
os.rename(user_path+'.back', user_path)
user = open(user_path, 'r').read().split(';')
else:
return False return False
user = open(os.path.join(config['runner_workdir'], '.users'), 'r').read().split(';')
salt = "runner81" #to be changed salt = "runner81" #to be changed
current_pwd = hashlib.md5( salt + pwd ).hexdigest() current_pwd = hashlib.md5( salt + pwd ).hexdigest()
if current_pwd == user[1]: if current_pwd == user[1]:
...@@ -102,8 +110,6 @@ def updateProxy(config): ...@@ -102,8 +110,6 @@ def updateProxy(config):
sr_request = slap.registerOpenOrder().request(profile, partition_reference=getSoftwareReleaseName(config), sr_request = slap.registerOpenOrder().request(profile, partition_reference=getSoftwareReleaseName(config),
partition_parameter_kw=partition_parameter_kw, software_type=None, partition_parameter_kw=partition_parameter_kw, software_type=None,
filter_kw=None, state=None, shared=False) filter_kw=None, state=None, shared=False)
#open(param_path, 'w').write(xml_marshaller.dumps(sr_request.
# getInstanceParameterDict()))
return True return True
def readPid(file): def readPid(file):
......
...@@ -17,7 +17,10 @@ def before_request(): ...@@ -17,7 +17,10 @@ def before_request():
and request.path != '/login' \ and request.path != '/login' \
and request.path != '/doLogin' and not request.path.startswith('/static'): and request.path != '/doLogin' and not request.path.startswith('/static'):
return redirect(url_for('login')) return redirect(url_for('login'))
if session.has_key('account') and session['account']:
session['title'] = getProjectTitle(app.config) session['title'] = getProjectTitle(app.config)
session['account'] = open(os.path.join(app.config['runner_workdir'], '.users'),
'r').read().split(';')
# general views # general views
@app.route('/') @app.route('/')
...@@ -33,7 +36,7 @@ def login(): ...@@ -33,7 +36,7 @@ def login():
@app.route("/myAccount") @app.route("/myAccount")
def myAccount(): def myAccount():
return render_template('account.html', username=session['account'][0], return render_template('account.html', username=session['account'][0],
email=session['account'][2], name=session['account'][3]) email=session['account'][2], name=session['account'][3].decode('utf-8'))
@app.route("/logout") @app.route("/logout")
def logout(): def logout():
...@@ -447,20 +450,23 @@ def getParameterXml(request): ...@@ -447,20 +450,23 @@ def getParameterXml(request):
@app.route("/updateAccount", methods=['POST']) @app.route("/updateAccount", methods=['POST'])
def updateAccount(): def updateAccount():
account = session['account'] account = session['account'][:] #copy session data
user = os.path.join(app.config['runner_workdir'], '.users') user = os.path.join(app.config['runner_workdir'], '.users')
try: try:
if request.form['username'].strip(): if request.form['username'].strip():
account[0] = request.form['username'].strip() account[0] = request.form['username'].strip()
account[2] = request.form['email'].strip() account[2] = request.form['email'].strip()
account[3] = request.form['name'].strip().encode("utf-8") account[3] = request.form['name'].strip()
if request.form['password'].strip(): if request.form['password'].strip():
account[1] = 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 #save new account data
open(user, 'w').write(';'.join(account)) open(user, 'w').write((';'.join(account)).encode("utf-8"))
session['account'] = account session['account'] = account
return jsonify(code=1, result="") return jsonify(code=1, result="")
except Exception, e: except Exception, e:
os.remove(user) os.remove(user)
open(user, 'w').write(';'.join(session['account'])) os.rename(user+'.back', user)
return jsonify(code=0, result=str(e)) return jsonify(code=0, result=str(e))
\ 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