def index(): """[summary] Returns: [type] -- [description] """ if "jwt_token" in session and session["jwt_token"] is not None: session["cidc_user_info"] = get_user_info(session["jwt_token"]) # This will be None if the user's token was invalid for any reason. if session["cidc_user_info"] is not None: # If the user is logged in, direct them to their roles homepage. if session["cidc_user_info"]["role"] == CIMAC_BIOFX_ROLE: return redirect(url_for_with_prefix("/cimac_biofx/home")) elif session["cidc_user_info"]["role"] == REGISTRANT_ROLE: # Check if user's registration is filled out. if session["cidc_user_info"]["registered"]: return redirect(url_for_with_prefix("/register")) return redirect(url_for_with_prefix("/request_pending")) elif session["cidc_user_info"]["role"] == ADMIN_ROLE: return redirect(url_for_with_prefix("/trials-summary")) # The user's JWT was invalid but they have a session, clear their session and start over again. return redirect(url_for_with_prefix("/logout")) return redirect(url_for_with_prefix("/login"))
def base_user_info(session): if "jwt_token" in session: session["cidc_user_info"] = get_user_info(session["jwt_token"]) if session["cidc_user_info"] is not None: return dict( user_role=session["cidc_user_info"]["role"], user_name=session["cidc_user_info"]["username"], clinical_trials_status_url=url_for_with_prefix( "/trials-summary"), cimac_biofx_home_url=url_for_with_prefix("/cimac_biofx/home"), cli_install_url=url_for_with_prefix( "/cimac_biofx/cli-install"), olink_upload_url=url_for_with_prefix( "/cimac_biofx/olink-upload"), upload_status_url=url_for_with_prefix("/cimac_biofx/uploads"), admin_home_url=url_for_with_prefix("/admin/home"), browse_files_url=url_for_with_prefix("/browse-files"), wes_pipelines_url=url_for_with_prefix("/wes-pipeline"), wes_upload_instructions_url=url_for_with_prefix("/wes-upload"), privacy_url=url_for_with_prefix("/privacy"), logout_url=url_for_with_prefix("/logout"), user_info_url=url_for_with_prefix("/admin/user_info"), ) return dict()
def remove_upload(): session["cidc_user_info"] = get_user_info(session["jwt_token"]) data_id = request.form.get("data_id") remove_data_record(session["jwt_token"], data_id) return redirect(url_for_with_prefix("/cimac_biofx/uploads"))
def home(): session["cidc_user_info"] = get_user_info(session["jwt_token"]) user_home_data = get_cimac_biofox_user_home_data(session["jwt_token"]) return render_template("home.jinja2", jwt=session["jwt_token"], user_home_data=user_home_data)
def uploads(): session["cidc_user_info"] = get_user_info(session["jwt_token"]) olink_uploads = get_olink_status(session["jwt_token"]) return render_template("upload_status.jinja2", jwt=session["jwt_token"], olink_uploads=olink_uploads, remove_uploaded_file_url=url_for_with_prefix( "/cimac_biofx/remove-upload"))
def callback_controller(): """[summary] Returns: [type] -- [description] """ session["jwt_token"], user_payload = callback_handling(auth0) # After login, get user's info from Eve session["cidc_user_info"] = get_user_info(session["jwt_token"]) session["user_name"] = user_payload["email"] return redirect(url_for_with_prefix("/"))
def register(): """[summary] Returns: [type] -- [description] """ session["cidc_user_info"] = get_user_info(session["jwt_token"]) if session["cidc_user_info"]["role"] is None: return redirect(url_for_with_prefix("/logout")) # If a user has already submitted a registration, bounce them to wait page. if session["cidc_user_info"]["registered"]: return redirect(url_for_with_prefix("/request_pending")) register_form = RegistrationForm(request.form) # Form submission method. if request.method == "POST": if register_form.validate(): update_user_info(session["jwt_token"], register_form) send_mail( "[CIDC][AUTOMATED] USER SIGNUP", "A new user has signed up for the CIDC Portal (%s)" % register_form.contact_email.data, CIDC_MAILING_LIST, ) return redirect(url_for_with_prefix("/request_pending")) else: render_template( "register.jinja2", save_url=url_for_with_prefix("/register"), register_form=register_form, ) return render_template( "register.jinja2", save_url=url_for_with_prefix("/register"), register_form=register_form, )
def request_pending(): """[summary] Returns: [type] -- [description] """ session["cidc_user_info"] = get_user_info(session["jwt_token"]) if session["cidc_user_info"]["role"] is None: return redirect(url_for_with_prefix("/logout")) # If a previously registered/accepted user visits this page, redirect them to the index. if session["cidc_user_info"]["role"] != REGISTRANT_ROLE: return redirect(url_for_with_prefix("/")) # If a user makes it here without filling out registration form, bounce them there. if not session["cidc_user_info"]["registered"]: return redirect(url_for_with_prefix("/register")) return render_template("request-pending.jinja2")
def olink_upload(): session["cidc_user_info"] = get_user_info(session["jwt_token"]) return render_template("olink-upload.jinja2", jwt=session["jwt_token"])
def cli_install(): session["cidc_user_info"] = get_user_info(session["jwt_token"]) return render_template("cli-install.jinja2", jwt=session["jwt_token"])
def wes_upload_instructions(): session["cidc_user_info"] = get_user_info(session["jwt_token"]) return render_template('react.jinja2')
def wes_pipeline(): session["cidc_user_info"] = get_user_info(session["jwt_token"]) return render_template('react.jinja2')
def browse_files(): session["cidc_user_info"] = get_user_info(session["jwt_token"]) return render_template('react.jinja2')