[docs]defredirect_to_principal_page(is_professional):""" Redirects the authenticated current user to its corresponding principal page. - USER: Goes to /chatbot - PROFESSIONAL: Goes to /internal/dashboard Args: is_professional (bool): Indicates if the user is a professional or not. Returns: Response: Redirect response to the user's principal page. """fromappimportCHATBOT_URL,DASHBOARD_URLifis_professional:returnredirect(url_for(DASHBOARD_URL))returnredirect(url_for(CHATBOT_URL))
[docs]defstandard_user_required(f):""" A decorator function to ensure standard users have access to the allowed views. If user is not standard, it aborts with a 403 Forbidden error. """@wraps(f)defdecorated_function(*args,**kwargs):ifcurrent_user.is_professional:abort(403)returnf(*args,**kwargs)returndecorated_function
[docs]defprofessional_user_required(f):""" A decorator function to ensure professional users have access to the allowed views. If user is not professional, it aborts with a 403 Forbidden error. """@wraps(f)defdecorated_function(*args,**kwargs):ifnotcurrent_user.is_professional:abort(403)returnf(*args,**kwargs)returndecorated_function