Пример #1
0
def register_auth():
    '''
    signup authorization
    '''
    username = request.form['username']
    password = request.form['password']
    retyped_pass = request.form['repass']
    print(db.registered(username))
    if username == "":
        flash("Enter a username")
        return redirect(url_for('signup'))
    if not db.registered(username):
        flash("Choose a different username")
        return redirect(url_for('signup'))
    elif password == "":
        flash("Enter a password")
        return redirect(url_for('signup'))
    elif password != retyped_pass:
        flash("Passwords do not match")
        return redirect(url_for('signup'))
    else:
        if db.add_user(username, password):
            flash("You have successfully registered")
        else:
            flash("This username is already in use")
            return redirect(url_for('signup'))
    db.auth_user(username, password)
    session['user'] = username
    return redirect('/')
Пример #2
0
def authenticate():
    if db.auth_user(request.form["user"], request.form["password"]):
        session["logged_in"] = request.form["user"]
        return redirect(url_for("home"))
    else:
        flash("username or password is incorrect")
        return redirect(url_for("login"))
Пример #3
0
def auth():
    given_user = request.form["username"]
    given_pwd = request.form["password"]
    if db.auth_user(given_user, given_pwd):
        session["logged_in"] = given_user
        return redirect(url_for("home"))
    else:
        flash("Username or password is incorrect")
        return redirect(url_for("login"))
Пример #4
0
def authenticate():
    try:
        if db.auth_user(request.args["user"], request.args["password"]):
            session["logged_in"] = request.args["user"]
            return redirect(url_for("home"))
        else:
            flash("username or password is incorrect")
            return redirect(url_for("login"))
    except:
        flash("Something went wrong :(")
        return redirect(url_for("home"))
Пример #5
0
def login_auth():
    '''
    login authorization
    '''
    username = request.form['username']
    password = request.form['password']
    if db.auth_user(username, password):
        session['user'] = username
        flash("You have logged in")
        return redirect('/')
    else:
        flash("Invalid username and password combination")
        return render_template('login.html')
Пример #6
0
def auth():
    return_page = "home"

    for each in request.form:
        if request.form[each] == "Login":
            return_page = each

    given_user = request.form["username"]
    given_pwd = request.form["password"]
    if db.auth_user(given_user, given_pwd):
        session["logged_in"] = given_user
        return redirect(url_for(return_page))
    else:
        flash("Username or password is incorrect")
        return redirect(url_for("login"))