Ejemplo n.º 1
0
def changePasswd(request):
  reponse = dict()
  reponse.update(status = 0, msg = '录入信息错误,请重新录入!')
  if not userApi.checkUserAuth(request):
    reponse.update(msg = '请重新登录系统重试!')
    return HttpResponse(json.dumps(reponse),mimetype='application/json')
    
  msg = ''
  if request.method == 'POST':
    form = ChangePasswdForm(request.POST)
    if form.is_valid():
      if not userApi.authService(form.cleaned_data['userId'], form.cleaned_data['passwd']):
        msg = '密码不正确!'
      else:
        userInfo = userApi.getUserByUserId(form.cleaned_data['userId'])
        userInfo.passwd = form.cleaned_data['repasswd']
        userInfo.put();
        msg = '修改密码成功!'
        reponse.update(status = 1)
  if msg != '':
    reponse.update(msg = msg)
  return HttpResponse(json.dumps(reponse),mimetype='application/json')