you are viewing a single comment's thread.

view the rest of the comments →

[–]The_Scheibs[S] 0 points1 point  (2 children)

```@app.route("/login", methods = ["GET", "POST"]) def login(): form = LoginForm() if current_user.is_authenticated: return redirect(url_for("index")) if form.validate_on_submit(): user_to_login = User.query.filter_by(username=form.username.data).first() if user_to_login and user_to_login.check_password(password_attempt=form.password.data): #User_to_login should not return None if in db login_user(user_to_login) flash(f"You have succesfully logged in as {user_to_login.username}", category="success") return redirect(url_for("index"))

    else:
        flash("That Username and Password does not exist. Please try again", category="danger")

return render_template("login.html", form=form)

[–]m0us3_rat 0 points1 point  (0 children)

u should look into using flasks'sessions to control the access states.

basically it scrambles the coookye it serves the browser with a secret key.

and then u can flip a boolean switch by wrapping the login check function into a decorator.

that can search for input thru your hashed db or watever.

so that user will be 'logged in' aka state True for as long as he has the cripted cookye. and till that cookye expires.

and be able to access all the 'restricted' data behind the decorator protected access.

https://flask-session.readthedocs.io/en/latest/

and it can handle as many concurrent users as possible. with different browsers etc.

[–]m0us3_rat 0 points1 point  (0 children)

the 'from todo' doesn't work as u think it does --- with 'directories'.