Logged in userd -- how to allow home page access without re-redirect?
Basically I just want to allow the user to go to the home page when they're logged in and see it as normal without re-directing to the dashboard. I've found a ton of re-direct rules but don't see one for this instance. Any tips?
thanks
Hi there,
Are you referring to Wave? I believe that you should be able to visit the home page by default after you've logged in:
Usually, for Laravel by default this is defined in the app/Http/Middleware/RedirectIfAuthenticated.php
middleware where the you can define which route the user to be redirected if authenticated, but I don't think that this is the case for Wave.
But if you want to redirect the user to the home page right after the login rather than the /dashboard
page, you can change that in the app/Providers/RouteServiceProvider.php
file and update the public const HOME = '/dashboard';
line.
Let me know how it goes!
It depends on what technology you're using for your web application. If you're assign the flask you can start with this:
from flask import Flask, redirect, request, render_template, session
app = Flask(__name__)
@app.route("/")
def home():
if "logged_in" in session and session["logged_in"] == True:
return render_template("home.html")
else:
return redirect("/login")
@app.route("/login", methods=["GET", "POST"])
def login():
if request.method == "POST":
# Verify user credentials and set session variable
session["logged_in"] = True
return redirect("/")
else:
return render_template("login.html")
In this example, the home function checks if the user is logged in by checking the value of the logged_in session variable. If the user is logged in, they are shown the home page, otherwise they are redirected to the login page. The login function handles both the display of the login page and the verification of user credentials. If the user provides correct credentials, the logged_in session variable is set to True and the user is redirected to the home page. I think it might help but if you need more explanation feel free to ask.