def _get_next_step(current_step): # I know this kind of logic requires O(2^N) different cases, but right now there's only 1 config # option that affects this list (it's the student photos enable/disable), so it's simplest to # express the 2 alternatives this way. # # When we add more features to the onboarding process, you can come up with a better, # generalized way of determining the onboarding steps. if config.student_photos_enabled: steps = ["onboarding.student_id", "onboarding.photo"] else: steps = ["onboarding.student_id"] if current_step is None: return steps[0] step_i = steps.index(current_step) if step_i == len(steps) - 1: # This is the final step of onboarding. # Authenticate the user and redirect them to the dashboard. with DbCursor() as c: user = get_user_by_github(c, github_username()) assert user user_id_, _, _, _, _, _ = user authenticate_as_user(user_id_) return "onboarding.welcome" else: return steps[step_i + 1]
def log_out(): if request.method == "POST": authenticate_as_user(None) authenticate_as_github_username(None) return redirect(url_for("onboarding.log_in")) elif github_username() or user_id(): return render_template("onboarding/log_out.html") else: return redirect(url_for("onboarding.log_in"))
def _get_current_step(): if is_ta(): return "ta.index" if user_id(): return "dashboard.index" github = github_username() if not github: return "onboarding.log_in" with DbCursor() as c: user = get_user_by_github(c, github) if not user: return "onboarding.student_id" user_id_, _, _, _, _, _ = user if config.student_photos_enabled: photo = get_photo(c, user_id_) if not photo: return "onboarding.photo" authenticate_as_user(user_id_) return "dashboard.index"
def login_as(): user_id = request.form.get("f_user_id") if not user_id: abort(400) authenticate_as_user(user_id) return redirect(url_for("dashboard.index"))