Beispiel #1
0
def delUser(request):
  reponse = dict()
  reponse.update(status = 0, msg = '请重新登录系统!')
  formPost = UserAuthForm()
  formCookie = UserAuthForm()
  if request.POST:
    formPost = UserAuthForm(request.POST)
  if request.COOKIES:
    formCookie = UserAuthForm(request.COOKIES)
  
  if formCookie.is_valid():
    userLoginId = formCookie.cleaned_data['userLoginId']
    userLoginAuth = formCookie.cleaned_data['userLoginAuth']
    if tools.getSession(userLoginId) == userLoginAuth:
      tools.delSession(userLoginId)
      userInfo = getUserByUserId(userLoginId)
      userInfo.delete()
      reponse.update(status = 1, msg = '注销用户成功!')
      return HttpResponse(json.dumps(reponse),mimetype='application/json');
      
  if formPost.is_valid():
    userLoginId = formPost.cleaned_data['userLoginId']
    userLoginAuth = formPost.cleaned_data['userLoginAuth']
    if tools.getSession(userLoginId) == userLoginAuth:
      tools.delSession(userLoginId)
      userInfo = getUserByUserId(userLoginId)
      userInfo.delete()
      reponse.update(status = 1, msg = '注销用户成功!')
      return HttpResponse(json.dumps(reponse),mimetype='application/json');
      
  return HttpResponse(json.dumps(reponse),mimetype='application/json');
Beispiel #2
0
def delUserAuth(request):
  form = UserAuthForm();
  if request.method == 'POST':
    form = UserAuthForm(request.POST)
  else:
    form = UserAuthForm(request.COOKIES)
  if form.is_valid():
    userLoginId = form.cleaned_data['userLoginId']
    if tools.getSession(userLoginId):
      tools.delSession(userLoginId)
      return True;
      
  return False;