Stay logged in on certain routes (#392)

This commit adds the @auth_desired decorator to
routes that previous had the @auth_required decorator,
but had it removed in #374. This should cause
the user to remain logged in on these routes.
This commit is contained in:
electricwhisk 2022-10-27 23:16:22 -04:00 committed by GitHub
parent b46ada9f72
commit 9f042c1aeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 1 deletions

View file

@ -752,21 +752,25 @@ def api_is_available(name):
return {name: True}
@app.get("/id/<id>")
@auth_desired
def user_id(id):
user = get_account(id)
return redirect(user.url)
@app.get("/u/<username>")
@auth_desired
def redditor_moment_redirect(username):
return redirect(f"/@{username}")
@app.get("/@<username>/followers")
@auth_desired
def followers(username, v=None):
u = get_user(username, v=v)
users = g.db.query(User).join(Follow, Follow.target_id == u.id).filter(Follow.user_id == User.id).order_by(Follow.created_utc).all()
return render_template("followers.html", v=v, u=u, users=users)
@app.get("/@<username>/following")
@auth_desired
def following(username, v=None):
u = get_user(username, v=v)
users = g.db.query(User).join(Follow, Follow.user_id == u.id).filter(Follow.target_id == User.id).order_by(Follow.created_utc).all()