def api_login(db): name = request.GET.get('name') or request.forms.get('name') or '' password = request.GET.get('password') or request.forms.get('password') or '' client_ip = request.remote_addr or '' user_agent = request.environ.get('HTTP_USER_AGENT') or '' tdb = TokenDB(db) pattern = tdb.text_encode(str(client_ip) + str(user_agent)) ret = tdb.admin_login(name, password, pattern) response.content_type = 'application/json' return json.dumps(ret)
def api_login(db): name = request.GET.get('name') or request.forms.get('name') or '' password = request.GET.get('password') or request.forms.get( 'password') or '' client_ip = request.remote_addr or '' user_agent = request.environ.get('HTTP_USER_AGENT') or '' tdb = TokenDB(db) pattern = tdb.text_encode(str(client_ip) + str(user_agent)) ret = tdb.admin_login(name, password, pattern) response.content_type = 'application/json' return json.dumps(ret)
def api_status(db): name = request.GET.get('name') or request.forms.get('name') or '' token = request.GET.get('token') or request.forms.get('token') or '' #print 'Name:', name, ',Token:', token ''' check login ''' tdb = TokenDB(db) ret = tdb.admin_check(name, token) if ret['status'] == False: response.content_type = 'application/json' return json.dumps({'status': False, 'data': 'need login'}) ''' get other info ''' return ret
def api_login(db): name = request.GET.get('name') or request.forms.get('name') or '' token = request.GET.get('token') or request.forms.get('token') or '' destroy_tokens = request.GET.get('destroy') or request.forms.get('destroy') or '' tdb = TokenDB(db) if destroy_tokens <> '': ret = tdb.admin_check(name, token) if ret['status']: ret = tdb.admin_token_destory_all(name) else: ret = tdb.admin_logout(name, token) response.content_type = 'application/json' return json.dumps(ret)
def api_status(db): name = request.GET.get('name') or request.forms.get('name') or '' token = request.GET.get('token') or request.forms.get('token') or '' #print 'Name:', name, ',Token:', token ''' check login ''' tdb = TokenDB(db) ret = tdb.admin_check(name, token) if ret['status'] == False: response.content_type = 'application/json' return json.dumps({'status':False,'data':'need login'}) ''' get other info ''' return ret
def api_login(db): name = request.GET.get('name') or request.forms.get('name') or '' token = request.GET.get('token') or request.forms.get('token') or '' destroy_tokens = request.GET.get('destroy') or request.forms.get( 'destroy') or '' tdb = TokenDB(db) if destroy_tokens <> '': ret = tdb.admin_check(name, token) if ret['status']: ret = tdb.admin_token_destory_all(name) else: ret = tdb.admin_logout(name, token) response.content_type = 'application/json' return json.dumps(ret)
def api_change_password(db): name = request.GET.get('name', '').strip() token = request.GET.get('token', '').strip() password = request.GET.get('password', '') if password == '' or token == '' or name == '': response.content_type = 'application/json' return json.dumps({'status': False}) ''' check login ''' tdb = TokenDB(db) ret = tdb.admin_check(name, token) if ret['status'] == False: response.content_type = 'application/json' return json.dumps({'status': False, 'data': 'need login'}) ''' change password ''' ret = tdb.admin_change_password(name, password) response.content_type = 'application/json' return json.dumps(ret)
def api_change_password(db): name = request.GET.get('name', '').strip() token = request.GET.get('token', '').strip() password = request.GET.get('password', '') if password == '' or token == '' or name == '': response.content_type = 'application/json' return json.dumps({'status':False}) ''' check login ''' tdb = TokenDB(db) ret = tdb.admin_check(name, token) if ret['status'] == False: response.content_type = 'application/json' return json.dumps({'status':False,'data':'need login'}) ''' change password ''' ret = tdb.admin_change_password(name, password) response.content_type = 'application/json' return json.dumps(ret)