Example #1
0
def index():
    title = 'Terminal Trader'
    h1 = "Terminal Trader"
    form = SignIn()
    if request.method == "GET":
        return render_template('index.html', form=form, title=title, h1=h1)
    elif request.method == "POST":
        if form.validate_on_submit():
            #FIXME CONTINUE HERE - connect to db
            if 'user exists in db':
                return "Email exists ---------"
            else:
                print("Email does not exist - redirect to Sign up")
                return redirect(url_for(signup))
        else:
            return "Form did not validate"
Example #2
0
def signin():
    form = SignIn(request.form)
    try:
        _username = request.form['user']
        _password = form.password.data

        data = acessa_sql('SELECT PASSWD FROM PASS WHERE LOGIN="******";')

        if len(data) > 0:
            me = User(_username, _password)
            if me.verifica_password(str(data[0][0]), _password):
                session['user'] = _username
                return redirect('/admin')
            else:
                return render_template('signin.html',
                                       error='Email ou senha errados.',
                                       form=form)
        else:
            return render_template('signin.html',
                                   error='Email ou senha errados.',
                                   form=form)

    except:
        return render_template('signin.html', form=form)
Example #3
0
def home():
    form = SignIn()
    if request.method == "GET":
        return render_template("home.html", form=form)

    elif request.method == "POST":
        if form.validate() == True:
            userData = userAuth(form.username.data, form.password.data)
            session["email"] = userData["email"]
            return redirect(url_for("myprofile"))
        elif form.validate() == False:
            flash("All fields are required")
            return render_template("signin.html", form=form)

    else:
        flash("Your username/email or password is incorrect")
        return render_template("signin.html")
Example #4
0
def sign_in():
    '''
    로그인 화면
    '''
    sign_in_form = SignIn()
    if sign_in_form.validate_on_submit():
        inputEmail = sign_in_form.data.get("inputEmail")
        inputPassword = sign_in_form.data.get("inputPassword")

        email_check = db.session.query(User).filter(
            User.email == inputEmail).first()
        if email_check is None:
            flash("존재하지 않는 이메일입니다.", "email_error")
        else:
            if email_check.password == inputPassword:
                session['sign_in'] = email_check.id

                return redirect("/")
            else:
                flash("비밀번호가 일치하지 않습니다.", "password_error")

    return render_template('sign_in.html', sign_in_form=sign_in_form)
Example #5
0
def signin():
    form = SignIn()
    if request.method == "GET":
        if "email" in session:
            userData = users_collection.find({"email": session["email"]})
            return redirect(url_for("myprofile"))
        else:
            return render_template("signin.html", form=form)

    elif request.method == "POST":
        if form.validate_on_submit():
            if userAuth(form.username.data, form.password.data) != None:
                userData = userAuth(form.username.data, form.password.data)
                session.pop("email", None)
                session["email"] = userData["email"]
                return redirect(url_for("myprofile"))
            else:
                flash("Your username or password was incorrect")
                return render_template("signin.html", form=form)
        else:
            flash("All fields are required")
            return render_template("signin.html", form=form)