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 Body -->
<!-- Menu Footer--> <!-- Menu Footer-->
<li class="user-footer"> <li class="user-footer" style="background-color:#e6e6e6">
<div class="pull-left"> <div class="pull-left">
<a href="/user/info/" class="btn btn-default btn-flat">Profile</a> <a href="/user/info/" class="btn btn-default btn-flat">Profile</a>
</div> </div>

View File

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

View File

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