示例#1
0
文件: views.py 项目: Forkong/Xianzhi
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))
示例#2
0
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())
示例#3
0
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())
示例#4
0
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))