コード例 #1
0
ファイル: __init__.py プロジェクト: aykamko/ob2
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]
コード例 #2
0
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]
コード例 #3
0
ファイル: __init__.py プロジェクト: aykamko/ob2
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"))
コード例 #4
0
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"))
コード例 #5
0
ファイル: __init__.py プロジェクト: aykamko/ob2
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"
コード例 #6
0
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"
コード例 #7
0
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"))
コード例 #8
0
ファイル: __init__.py プロジェクト: cycomachead/ob2
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"))