def login(req): if req.method == 'GET': return render_to_response('login.html', locals(), context_instance = RequestContext(req)) data = fun.warp_data(req.POST) rt = controller.user_login(data) if rt: req.session['islogin'] = True user_info = {} user_info['id'] = rt.id user_info['name'] = rt.name user_info['email'] = rt.email req.session['user_info'] = user_info return HttpResponseRedirect('/') else: msg = '用户名或密码错误,登录失败!' return render_to_response('login.html', locals(), context_instance = RequestContext(req))
def login(req): msg = 'login page' if req.method == 'GET': msg = '你提交的方式非法!' return render_to_response('msg.html', locals()) data = fun.warp_data(req.POST) rt = controller.user_login(data) # print rt.id if rt: req.session['islogin'] = True user_info = {} user_info['id'] = rt.id user_info['name'] = rt.name user_info['email'] = rt.email req.session['user_info'] = user_info return HttpResponseRedirect('/') else: msg = '用户名或密码错误,登录失败!' return render_to_response('msg.html', locals())
def login(req): if req.method == 'GET': msg = '非法访问!!' return render_to_response('error_msg.html', locals()) else: data = req.POST rt = controller.user_login(data) if rt: #登录成功后,将用户信息添加到session中 req.session['islogin'] = True user_info = {} user_info['uid'] = rt.id user_info['name'] = rt.name user_info['email'] = rt.email user_info['phone'] = rt.phone req.session['user_info'] = user_info return HttpResponseRedirect('/') else: msg = '账号或密码错误!' return render_to_response('error_msg.html', locals())
def login(req): if req.method == 'GET': return render_to_response('login.html', locals(), context_instance=RequestContext(req)) data = fun.warp_data(req.POST) rt = controller.user_login(data) if rt: req.session['islogin'] = True user_info = {} user_info['id'] = rt.id user_info['name'] = rt.name user_info['email'] = rt.email req.session['user_info'] = user_info return HttpResponseRedirect('/') else: msg = '用户名或密码错误,登录失败!' return render_to_response('login.html', locals(), context_instance=RequestContext(req))