Now updating userinfo take effects immediately

Change background color of profile and signout button
This commit is contained in:
Peidong Liu 2016-04-04 21:13:19 +08:00
parent 1936fb6ce4
commit e9dfd7b395
3 changed files with 15 additions and 11 deletions

View File

@ -77,7 +77,7 @@
<!-- Menu Body -->
<!-- Menu Footer-->
<li class="user-footer">
<li class="user-footer" style="background-color:#e6e6e6">
<div class="pull-left">
<a href="/user/info/" class="btn btn-default btn-flat">Profile</a>
</div>

View File

@ -1,7 +1,7 @@
from webViews.view import normalView
from webViews.authenticate.auth import is_authenticated
from webViews.dockletrequest import dockletRequest
from flask import redirect, request, render_template, session, make_response
from flask import redirect, request, render_template, session, make_response, abort
from webViews import cookie_tool
import hashlib
@ -20,16 +20,18 @@ if (env.getenv('EXTERNAL_LOGIN') == 'True'):
import external_generate
def refreshInfo():
'''not used now'''
result = dockletRequest.post('/login/', data)
data = {}
result = dockletRequest.post('/user/selfQuery/', data)
ok = result and result.get('success', None)
session['username'] = request.form['username']
session['nickname'] = result['data']['nickname']
session['description'] = result['data']['description'][0:10]
session['avatar'] = '/static/avatar/'+ result['data']['avatar']
session['usergroup'] = result['data']['group']
session['status'] = result['data']['status']
session['token'] = result['data']['token']
if (ok and ok == "true"):
session['username'] = result['data']['username']
session['nickname'] = result['data']['nickname']
session['description'] = result['data']['description']
session['avatar'] = '/static/avatar/'+ result['data']['avatar']
session['usergroup'] = result['data']['group']
session['status'] = result['data']['status']
else:
abort(404)
class loginView(normalView):
template_path = "login.html"

View File

@ -1,5 +1,6 @@
from flask import redirect, request
from webViews.dockletrequest import dockletRequest
from webViews.authenticate import login
from webViews.view import normalView
import json
@ -15,4 +16,5 @@ class userinfoView(normalView):
@classmethod
def post(self):
result = json.dumps(dockletRequest.post('/user/selfModify/', request.form))
login.refreshInfo()
return result