예제 #1
0
 def get(self, request):
     token = request.GET.get('token')
     if token is None:
         return HttpResponseBadRequest('缺少参数')
     data = check_active_token(token)
     if data is None:
         return HttpResponseBadRequest('验证失败')
     id = data.get('id')
     email = data.get('email')
     try:
         user = User.objects.get(id=id, email=email)
     except User.DoesNotExist:
         return HttpResponseBadRequest('验证失败')
     else:
         user.email_active = True
         user.save()
     return redirect(reverse('users:center'))
예제 #2
0
 def get(self, request):
     # 1.获取token
     token = request.GET.get('token')
     if token is None:
         return HttpResponseBadRequest('缺少参数')
     # 2.token信息解密
     data = check_active_token(token)
     if data is None:
         return HttpResponseBadRequest('验证失败')
     # 3.根据用户信息进行数据更新
     id = data.get('id')
     email = data.get('email')
     # 4.查询用户
     try:
         user = User.objects.get(id=id, email=email)
     except User.DoesNotExist:
         return HttpResponseBadRequest('验证失败')
     # 设置邮件激活状态
     user.email_active = True
     user.save()
     # 5.跳转到个人中心页面
     return redirect(reverse('users:center'))
예제 #3
0
 def get(self, request):
     # ①获取token信息
     token = request.GET.get('token')
     if token is None:
         return HttpResponseBadRequest('缺少参数')
     # ②token信息解密
     data = check_active_token(token)
     if data is None:
         return HttpResponseBadRequest('验证失败')
     # ③根据用户信息进行数据的更新
     id = data.get('id')
     email = data.get('email')
     # 我们需要查询指定用户 ,request.user 可能没有登陆用户信息
     # User.objects.filter().filter()
     try:
         user = User.objects.get(id=id, email=email)
     except User.DoesNotExist:
         return HttpResponseBadRequest('验证失败')
     user.email_active = True
     user.save()
     # ④跳转到指定页面
     return redirect(reverse('users:center'))