def updatePwd(request): response = Response.ResponseObj() user_id = request.GET.get('user_id') user_objs = models.xzh_userprofile.objects.filter(id=user_id) if user_objs: user_obj = user_objs[0] user_obj_role = user_obj.role_id oldPwd = request.POST.get('oldPwd') newPwd = request.POST.get('newPwd') if newPwd and oldPwd: print('oldPwd-------> ',oldPwd) oldPwd = account.str_encrypt(oldPwd) # 加密 密码 if oldPwd == user_obj.password: newPwd = account.str_encrypt(newPwd) token = account.get_token(newPwd + str(int(time.time()) * 1000)) # token user_objs.update(password=newPwd, token=token) response.code = 200 response.msg = '修改成功' else: response.code = 301 response.msg = '旧密码验证错误' else: response.code = 301 response.msg = '参数错误' else: response.code = 500 response.msg = '非法请求' return JsonResponse(response.__dict__)
def start(): token = '87358e1e762b76cca29de2a14dd2a70f' user_id = 54 timestamp = str(int(time.time() * 1000)) params = { 'user_id': user_id, 'rand_str': str_encrypt(timestamp + token), 'timestamp': timestamp, } return params
def specialUserGenerateThePage(): print('==========================生成二级域名----===========================') timestamp = str(int(time.time() * 1000)) params = { 'user_id': user_id, 'rand_str': str_encrypt(timestamp + token), 'timestamp': timestamp, } url = 'http://xiongzhanghao.zhugeyingxiao.com:8003/api/specialUserGenerateThePage' print('url -->', url) requests.get(url, params=params)
def login(request): response = Response.ResponseObj() username = request.POST.get('username') password = request.POST.get('password') # 查询数据库 userprofile_objs = models.xzh_userprofile.objects.filter( username=username, # md5加密 密码 password=account.str_encrypt(password), status=1) if userprofile_objs: # 如果有数据 查询第一条对象 userprofile_obj = userprofile_objs[0] token = userprofile_obj.token # 如果没有token 则生成 token # if not userprofile_obj.token: # token = account.get_token(account.str_encrypt(password)) # userprofile_obj.token = token # else: response.code = 200 response.msg = '登录成功' time.time() # company_id = '' # if userprofile_obj.company_id: # company_id = userprofile_obj.company_id response.data = { 'token': token, 'user_id': userprofile_obj.id, 'set_avator': userprofile_obj.set_avator, 'username': userprofile_obj.username, 'role_id': userprofile_obj.role_id, } userprofile_obj.last_login_date = datetime.datetime.now() userprofile_obj.save() else: response.code = 401 response.msg = "账号或密码错误" return JsonResponse(response.__dict__)
def clean_password(self): password = self.data['password'] return account.str_encrypt(password)
from __future__ import absolute_import, unicode_literals from .celery import app import requests import time from xiongzhanghao.publicFunc.account import str_encrypt token = '87358e1e762b76cca29de2a14dd2a70f' user_id = 54 timestamp = str(int(time.time() * 1000)) params = { 'user_id': user_id, 'rand_str': str_encrypt(timestamp + token), 'timestamp': timestamp, } # print('params----------------> ',params) # 生成二级域名 @app.task def specialUserGenerateThePage(): print('==========================生成二级域名----===========================') timestamp = str(int(time.time() * 1000)) params = { 'user_id': user_id, 'rand_str': str_encrypt(timestamp + token), 'timestamp': timestamp, } url = 'http://xiongzhanghao.zhugeyingxiao.com:8003/api/specialUserGenerateThePage' print('url -->', url) requests.get(url, params=params)