예제 #1
0
파일: blog.py 프로젝트: drozas/mongodb
def process_login():

    connection = pymongo.Connection(connection_string, safe=True)

    username = bottle.request.forms.get("username")
    password = bottle.request.forms.get("password")

    print "user submitted ", username, "pass ", password

    userRecord = {}
    if (user.validate_login(connection, username, password, userRecord)):
        session_id = user.start_session(connection, username)
        if (session_id == -1):
            bottle.redirect("/internal_error")

        cookie = user.make_secure_val(session_id)

        # Warning, if you are running into a problem whereby the cookie being set here is 
        # not getting set on the redirct, you are probably using the experimental version of bottle (.12). 
        # revert to .11 to solve the problem.
        bottle.response.set_cookie("session", cookie)
        
        bottle.redirect("/welcome")

    else:
        return bottle.template("login", 
                           dict(username=cgi.escape(username), password="", 
                                login_error="Invalid Login"))
예제 #2
0
def process_login():

    connection = pymongo.Connection(connection_string, safe=True)

    username = bottle.request.forms.get("username")
    password = bottle.request.forms.get("password")

    print "user submitted ", username, "pass ", password

    userRecord = {}
    if (user.validate_login(connection, username, password, userRecord)):
        session_id = user.start_session(connection, username)
        if (session_id == -1):
            bottle.redirect("/internal_error")

        cookie = user.make_secure_val(session_id)

        # Warning, if you are running into a problem whereby the cookie being set here is
        # not getting set on the redirct, you are probably using the experimental version of bottle (.12).
        # revert to .11 to solve the problem.
        bottle.response.set_cookie("session", cookie)

        bottle.redirect("/welcome")

    else:
        return bottle.template(
            "login",
            dict(username=cgi.escape(username),
                 password="",
                 login_error="Invalid Login"))
예제 #3
0
파일: site.py 프로젝트: alexefremo/diploma
def process_login():

    connection = pymongo.MongoClient(connection_string)

    username = bottle.request.forms.get("username")
    password = bottle.request.forms.get("password")

    print "user submitted ", username, "pass ", password

    userRecord = {}
    if (user.validate_login(connection, username, password, userRecord)):
        session_id = user.start_session(connection, username)
        if (session_id == -1):
            bottle.redirect("/internal_error")

        cookie = user.make_secure_val(session_id)

        # не работает с bottle .12, откатитесь на версию .11
        bottle.response.set_cookie("session", cookie)
        
        bottle.redirect("/")

    else:
        return bottle.template("login", 
                           dict(username=cgi.escape(username), password="", 
                                login_error="неверно"))
예제 #4
0
def process_login():


    username = bottle.request.forms.get("username")

    if (username == None): 
        print "welcome: can't identify user...redirecting to signup" 
        bottle.redirect("/signup") 

    password = bottle.request.forms.get("password")

    print "user submitted ", username, "pass ", password

    userRecord = {}
    if (user.validate_login(connection, username, password, userRecord)):
        session_id = user.start_session(connection, username)
        if (session_id == -1):
            bottle.redirect("/internal_error")

        cookie = user.make_secure_val(session_id)

        bottle.response.set_cookie("session", cookie)

        bottle.redirect("/welcome")

    else:
        return bottle.template("login", dict(username=cgi.escape(username), password="", login_error="Invalid Login"))
예제 #5
0
def process_login():
    connection = pymongo.Connection(connection_string, safe=True)

    username = request.forms.get("username")
    password = request.forms.get("password")

    userRecord = {}
    if user.validate_login(connection, username, password, userRecord):
        # looks good. start a new session
        session_id = user.start_session(connection, username)
        if session_id is -1:
            redirect("/internal_error")

        cookie = user.make_secure_val(session_id)
        # send the cookie back to the user
        response.set_cookie("session", cookie)
        # full round trip here.
        redirect("/main")
    else:
        # not a valid login
        return template(
            "login",
            dict(username_value=cgi.escape(username),
                 password="",
                 username="",
                 login_error="Invalid Login"))
예제 #6
0
def login():
    username = request.form.get('username', '')
    password = request.form.get('password', '')
    if user.validate_login(username, password):
        return redirect('/users/')
    else:
        return render_template('login.html', username=username, error='用户名或密码错误')
예제 #7
0
def process_login():

    connection = MongoClient('localhost', 27017)

    username = bottle.request.forms.get("username")
    password = bottle.request.forms.get("password")

    print "user submitted ", username, "pass ", password

    userRecord = {}
    if (user.validate_login(connection, username, password, userRecord)):
        session_id = user.start_session(connection, username)
        if (session_id == -1):
            bottle.redirect("/internal_error")

        cookie = user.make_secure_val(session_id)

        bottle.response.set_cookie("session", cookie)

        bottle.redirect("/welcome")

    else:
        return bottle.template(
            "login",
            dict(username=cgi.escape(username),
                 password="",
                 login_error="Invalid Login"))
예제 #8
0
def process_login():

    connection = pymongo.Connection(connection_string, safe=True)

    username = bottle.request.forms.get("username")
    password = bottle.request.forms.get("password")

    userRecord = {}
    if user.validate_login(connection, username, password, userRecord):
        # looks good. start a new session
        session_id = user.start_session(connection, username)
        if session_id == -1:
            bottle.redirect("/internal_error")

        cookie = user.make_secure_val(session_id)
        # send the cookie back to the user
        bottle.response.set_cookie("session", cookie)

        # full round trip here.

        bottle.redirect("/welcome")

    else:
        # not a valid login
        return bottle.template("login", dict(username=cgi.escape(username), password="", login_error="Invalid Login"))
예제 #9
0
def process_login():

    connection = pymongo.Connection(connection_string, safe=True)

    username = bottle.request.forms.get("username")
    password = bottle.request.forms.get("password")

    print ("user submitted ", username, "pass ", password)

    userRecord = {}
    if (user.validate_login(connection, username, password, userRecord)):
        session_id = user.start_session(connection, username)
        if (session_id == -1):
            bottle.redirect("/internal_error")

        cookie = user.make_secure_val(session_id)

        
        bottle.response.set_cookie("session", cookie)
        
        bottle.redirect("/welcome")

    else:
        return bottle.template("login", 
                           dict(username=cgi.escape(username), password="", 
                                login_error="Invalid Login"))
예제 #10
0
def login():
	params = request.args if request.method == 'GET' else request.form
	username = params.get('username', '')
	password = params.get('password', '')
	if user.validate_login(username, password):
		return redirect('/logs/')
	else:
		return render_template('login.html', username=username, error='username or password is error')
예제 #11
0
def login():
	params = request.args if request.method == 'GET' else request.form
	username = params.get('user','')
	password = params.get('password','')

	if user.validate_login(username=username,password=password): #判断用户名密码是否正确
		return redirect('/users/')
	else:
		return render_template('login.html',error='用户名或密码错误') #不正确提示信息通过渲染模板实现把error的值传到login.html里面
예제 #12
0
def login():
    username = request.form.get('username', '')
    password = request.form.get('password', '')
    if user.validate_login(username, password):
        return redirect('/users/')
    else:
        return render_template('login.html',
                               username=username,
                               error='用户名或密码错误')
예제 #13
0
def login():
    try:
        params = request.args if request.method == 'GET' else request.form
        username = params.get('username', '')
        # print username
        password = params.get('password', '')
        # print password

        print user.validate_login(username, password)
        if user.validate_login(username, password):
            return redirect('/logs/')
        else:
            return render_template('login.html',
                                   username=username,
                                   error='username or password is error')
    except BaseException as e:
        print e
        return []
예제 #14
0
def login():
    params = request.args if request.method == 'GET' else request.form
    username = params.get('username', '')
    password = params.get('password', '')
    if user.validate_login(username, password):
        flash("%s,欢迎回来!" % username)
        return redirect('/show/')
    else:
        flash("用户名或密码错误,请重新输入!")
        return render_template('login.html', username=username)
예제 #15
0
def login():
    username = request.form.get('username', '')     #接收用户提交的数据
    password = request.form.get('password', '')

    #需要验证用户名密码是否正确
    print username, password
    if user.validate_login(username, password):
        return redirect('/users/')                  #跳转到url /users/
    else:
        #登录失败
        return render_template('login.html', username=username, error='用户名或密码错误')
예제 #16
0
def login():
    params = request.args if request.method == 'GET' else request.form
    username = params.get('username')
    password = params.get('password')
    if user.validate_login(username, password):
        print '登录成功'
        session['user'] = {'username': username}
        return redirect('/users/')
    else:
        return render_template('login.html',
                               username=username,
                               error=u'用户名或密码错误')
예제 #17
0
def login():
    username = request.form.get('username', '')     #接收用户提交的数据
    password = request.form.get('password', '')

    #需要验证用户名密码是否正确
    # print username, password
    if user.validate_login(username, password):
        session['user'] = {'username' : username}
        return redirect('/users/')                  #跳转到url /users/
    else:
        #登录失败
        return render_template('login.html', username=username, error=u'用户名或密码错误')
예제 #18
0
def login():
    if request.method == 'GET':
        return render_template('login.html')

    username = request.form.get('username')
    password = request.form.get('password')
    if user.validate_login(username, password):
        return redirect('/user/list/')
    else:
        return render_template('login.html',
                               username=username,
                               error=u'用户名或密码错误!')
예제 #19
0
def login():
    params = request.args if request.method == 'GET' else request.form
    username = params.get('username')  # 获取用户提交的"username"参数
    password = params.get('password')  # 获取用户提交的"password"参数

    if request.method == 'GET':
        return render_template('login.html')
    else:
        if user.validate_login(username, password):
            return redirect('/user/list/')
        else:
            return render_template('login.html',
                                   username=username,
                                   error=u'用户名或密码错误!')
예제 #20
0
파일: blog.py 프로젝트: erlichson/cs253
def process_login():
    username = bottle.request.forms.get("username")
    password = bottle.request.forms.get("password")
    userRecord = {}
    if (user.validate_login(username, password, userRecord)):
        session_id = user.start_session(userRecord['uid'])
        cookie = user.make_secure_val(str(int(session_id)))
        bottle.response.set_cookie("session", cookie)

        bottle.redirect("/blog/welcome")

    else:
        return bottle.template("login", 
                           dict(username=cgi.escape(username), password="", 
                                login_error="Invalid Login"))
예제 #21
0
def post_signin():
    email = bottle.request.forms.get("email")
    password = bottle.request.forms.get("password")

    if user.validate_login(email, password):
        session_id = user.start_session(email)

        if session_id == -1:
            bottle.redirect("/error")

        cookie = user.make_secure_val(session_id)

        bottle.response.set_cookie("session", cookie)
        bottle.redirect("/welcome")
    else:
        return bottle.template("login", {
            'email': cgi.escape(email),
            'password': '',
            'error': 'Invalid login'
        })
예제 #22
0
def login():
    # 第一步:获取用户名和密码数据
    # if request.method == 'GET':
    #     params = request.args
    # else:
    #     params = request.form
    # if 简写方法:
    params = request.args if request.method == 'GET' else request.form
    username = params.get('username')  # 获取用户提交的"username"参数
    password = params.get('password')  # 获取用户提交的"password"参数

    # 第二步:登录验证,成功返回页面,失败给出提示
    if user.validate_login(username, password):
        print '登录成功'
        # return redirect('/logs/')
        return redirect('/users/')
    else:
        print '登录失败'
        return render_template('login.html',
                               username=username,
                               error=u'用户名或密码错误')