Esempio n. 1
0
def settings_screen():
    logic_resp = SessionLogic.get()
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)
    _session = logic_resp.addon_data
    _session: m_Session
    return render_template("webapp/user/settings.html", session=_session)
Esempio n. 2
0
    def decorated_function(*args, **kwargs):
        logic_resp = SessionLogic.get()
        if not logic_resp.success:
            return Returns.return_message("Error connecting to the database!",
                                          "Try again later!", 5,
                                          rLanding.index.route_path)

        _session = logic_resp.addon_data
        _session: m_Session
        if not _session.User.is_admin:
            return Returns.return_message("You are not allowed to do this!",
                                          "^", 2, rAuth.logout.route_path)
        return f(*args, **kwargs)
Esempio n. 3
0
def add_friend():
    if request.method == 'GET':
        return render_template("webapp/user/confirm.html")

    logic_resp = SessionLogic.get()
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)
    _session = logic_resp.addon_data
    _session: m_Session
    print(request.form)
    logic_resp = ViewUserLogic.add_friend(_session, request.form)
    if not logic_resp.success:
        return Returns.return_message("Failed to add a friend!", logic_resp.content, 2, r.index.route_path)
    return Returns.return_message("Friend added!", logic_resp.content, 2, r.index.route_path)
Esempio n. 4
0
 def decorated_function(*args, **kwargs):
     debug.print_v("on needs_to_be_guest()")
     logic_resp = SessionLogic.get()
     if not logic_resp.success:
         debug.print_e(f"needs_to_be_guest: {logic_resp.content}")
         return Returns.return_message("Error connecting to the database!",
                                       "Please try again later!", 5,
                                       rLanding.index.route_path)
     User_Session = logic_resp.addon_data
     User_Session: m_Session
     if User_Session.logged_in:
         debug.print_w(f"needs_to_be_guest: already registered")
         return Returns.return_message("You are already registered!", "", 0,
                                       rUser.index.route_path)
     return f(*args, **kwargs)
Esempio n. 5
0
def fingerprints_screen(d_uuid):
    logic_resp = SessionLogic.get()
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)
    _session = logic_resp.addon_data
    _session: m_Session

    logic_resp = ViewUserLogic.get_allowed_users_for_findlock(d_uuid)
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)
    
    list_of_names = logic_resp.addon_data


    return render_template("webapp/user/fingerprint.html", list_of_names=list_of_names)
Esempio n. 6
0
def new_device():
    logic_resp = SessionLogic.get()
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)
    _session = logic_resp.addon_data
    _session: m_Session

    if request.method == 'GET':
        return render_template('user/new_device.html')

    logic_resp = ViewUserLogic.pair_with_findlock(
        _session, request.form
    )
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)
    return Returns.return_message("Paired!", "Nice!", 2, r.index.route_path)
Esempio n. 7
0
def update():
    logic_resp = SessionLogic.get()
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)
    _session = logic_resp.addon_data
    _session: m_Session

    if request.method == 'POST':
        logic_resp = ViewUserLogic.update_user_data(_session, request.form)
        if not logic_resp.success:
            return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)
        return redirect(r.index.route_path)

    logic_resp = ViewUserLogic.user_data_is_missing(_session)
    if not logic_resp.success:
        return Returns.return_message("Something went wrong", logic_resp.content, 2, r.index.route_path)
    return render_template('user/fill_in_data.html', missing_data=logic_resp.addon_data)
Esempio n. 8
0
def index():
    logic_resp = SessionLogic.get()
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)

    _session = logic_resp.addon_data
    _session: m_Session

    logic_resp = ViewUserLogic.user_data_is_missing(_session)
    if logic_resp.success:  # account misses some data
        return redirect(r.update.route_path)

    logic_resp = ViewUserLogic.get_user_findlocks(_session)
    if not logic_resp.success:
        return Returns.return_message("Failed!", logic_resp.content, 2, rAuth.logout.route_path)
    print(logic_resp.addon_data)
    return render_template("webapp/user/profile.html", Session=_session, findlocks=logic_resp.addon_data, findlocks_n=len(logic_resp.addon_data))
Esempio n. 9
0
def device(d_uuid):
    logic_resp = SessionLogic.get()
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)
    _session = logic_resp.addon_data
    _session: m_Session

    logic_resp = ViewUserLogic.user_allowed_to_use_findlock(_session, d_uuid)
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2,r.index.route_path)

    logic_resp  = ViewUserLogic.get_findlock_info(d_uuid)
    if not logic_resp.success:
        return Returns.return_message("Something went wrong!", logic_resp.content, 2, r.index.route_path)
    _findlock = logic_resp.addon_data
    _findlock: m_Findlock
    #return render_template("user/device.html", findlock=_findlock, session=_session)
    return render_template("webapp/user/home.html", findlock=_findlock, session=_session)
Esempio n. 10
0
    def decorated_function(*args, **kwargs):
        logic_resp = SessionLogic.get()
        if not logic_resp.success:
            return Returns.return_message("Error connecting to the database!",
                                          "Please try again later!", 5,
                                          rLanding.index.route_path)

        User_Session = logic_resp.addon_data
        User_Session: m_Session
        if not User_Session.logged_in:
            login_path = rAuth.index.route_path
            if request.path != rAuth.logout.route_path:
                login_path += f"?redirectUri={request.path}"
            return Returns.return_message("You need to be logged in!", "^", 2,
                                          login_path)
        if User_Session.User is None:
            return Returns.return_message("user session is corrupted!",
                                          "Please try again!", 2,
                                          rAuth.index.route_path)
        return f(*args, **kwargs)