def login(request): phonenum = request.POST.get('phonenum') vcode = int(request.POST.get('vcode')) if not check_vcode(phonenum, vcode): user, created = User.get_or_create(phonenum=phonenum) request.session['uid'] = user.id pre_rcmd(user) return render_json(user.to_dict()) else: raise errors.VcodeError
def login(request): phonenum = request.POST.get("phonenum") vcode = request.POST.get("vcode") if check_vcode(phonenum, vcode): raise errors.VcodeError else: user, created = User.objects.get_or_create(phonenum=phonenum) request.session['uid'] = user.id # uid是动态改变的,而且是唯一的一个key只对应一个value,假设当一个用户登录时uid=1,下一用户登录时uid就是=其他了 pre_rcmd(user) return render_json(user.to_dict())
def login(request): '''短信验证登录''' phonenum = request.POST.get('phonenum') vcode = request.POST.get('vcode') if not check_vcode(phonenum, vcode): # 获取用户 user, created = User.objects.get_or_create(phonenum=phonenum) # 记录登录状态 request.session['uid'] = user.id pre_rcmd(user) return render_json(user.to_dict()) else: return render_json(None, error.OK)
def user_back(request): pre_rcmd(request.user) return render_json(None)
def user_back(request): # 系统推荐用户功能前需要触发登录接口,但是考虑到用户不能持续的调用登录接口(因为手机中有监听该功能可以自动调用我们服务器中的含有用户session的登录接口),所以 # 此接口就是一个免用户手动登录的触发接口 pre_rcmd(request.user) #推荐算法的预处理 return render_json(None)