Ejemplo n.º 1
0
def do_login():
    if request.form.get("username") == USER_NAME and request.form.get(
            'password') == PWD:
        user = User(USER_NAME)
        logout_user()
        return redirect("/index.html")
    return redirect("/login")
Ejemplo n.º 2
0
def logout():
    try:
        logout_user()
        flash('Logout done successfully.', 'success')
    except Exception as exception:
        flash('An error occurred while logging out.', 'error')
    return redirect(url_for('index'))
Ejemplo n.º 3
0
def auth_delete():
    id = current_user.id
    logout_user()

    stmt = text("DELETE FROM account WHERE id = :id").params(id=id)
    db.engine.execute(stmt)
    return redirect(url_for("home"))
Ejemplo n.º 4
0
def logout():
    loginuser = request.args.get("loginuser")
    userip = get_oper_ip_info(request)
    if get_log_switch():
        send2icsp_content = LOGIN_CONTENT % (loginuser, userip)
        send_logout_to_icsp(send2icsp_content)
    logout_user()
    return render_template('/login.html')
Ejemplo n.º 5
0
def make_session_permanent():
    now = datetime.datetime.now()
    last_active = session.get("last_active")
    if last_active:
        delte = now - last_active
        if delte.seconds > SCUT:
            session['last_active'] = now
            logout_user()
        session['last_active'] = now
Ejemplo n.º 6
0
def logout_action():
    try:
        current_user.authenticated = False
        logout_user()
        flash("로그아웃 되었습니다.")
        return redirect(url_for("main_view.index"))
    except Exception as e:
        logger.info(str(e))
        raise e
Ejemplo n.º 7
0
def test_access_encrypted_storage_after_login(app_no_node: SpecterFlask):
    """ServiceEncryptedStorage should be accessible (decryptable) after user login"""
    # Create test users; automatically generates their `user_secret` and kept decrypted
    # in memory.
    user_manager: UserManager = app_no_node.specter.user_manager
    user_manager.create_user(
        user_id="bob",
        username="******",
        plaintext_password="******",
        config={},
    )
    user_manager.create_user(
        user_id="alice",
        username="******",
        plaintext_password="******",
        config={},
    )

    # The ServiceEncryptedStorageManager singleton creates a mess in the test suite. Have
    # to override its (potentially) already-set values with references to this test's
    # new instances and temp storage dir.
    storage_manager = ServiceEncryptedStorageManager.get_instance()
    storage_manager.data_folder = user_manager.data_folder
    storage_manager.user_manager = user_manager
    storage_manager.storage_by_user = {}

    # Need a simulated request context to enable `current_user` lookup
    with app_no_node.test_request_context():
        login_user(user_manager.get_user("bob"))

        # Test user's service_data should be decryptable but initially empty
        service_data = storage_manager.get_current_user_service_data(
            service_id=FakeService.id)
        assert service_data == {}
        storage_manager.update_current_user_service_data(
            service_id=FakeService.id, service_data={"somekey": "green"})

        logout_user()

        # Meanwhile Alice's account storage will still be blank...
        login_user(user_manager.get_user("alice"))
        service_data = storage_manager.get_current_user_service_data(
            service_id=FakeService.id)
        assert (storage_manager.get_current_user_service_data(
            service_id=FakeService.id) == {})

        logout_user()

        # ...while Bob's can be retrieved when he's logged in.
        login_user(user_manager.get_user("bob"))
        service_data = storage_manager.get_current_user_service_data(
            service_id=FakeService.id)
        assert storage_manager.get_current_user_service_data(
            service_id=FakeService.id) == {
                "somekey": "green"
            }
Ejemplo n.º 8
0
def logout():
    """
    Logout user view.
    :return: HTTP Response
    """

    if current_user.is_authenticated:
        logout_user()

    return redirect(url_for('core.home'))
Ejemplo n.º 9
0
def api_logout():
    try:
        current_user.authenticated = False
        #tmp_id = str(current_user.id)
        logout_user()
        session.clear()
        flash("로그아웃 되었습니다.")
        return redirect(url_for("main_view.main"))
    except Exception as e:
        logger.info(str(e))
Ejemplo n.º 10
0
def logout(reportdirname):
    """View to process login form data and login user in case.
    """
    try:
        _logout(current_user.id)
    except:
        pass  # FIXME: better handling?
    finally:
        logout_user()

    return jsonify({})  # FIXME: what to return?
Ejemplo n.º 11
0
def settings_page():
    if request.method == 'POST':
        if request.form['action'] == 'deleteUser':
            with dbapi2.connect(app.config['dsn']) as connection:
                cursor = connection.cursor()

                query = """DELETE FROM USERS WHERE ( USERNAME=%s )"""
                cursor.execute(query, ([current_user.userName]))

                connection.commit()
            logout_user()
            return redirect(url_for('home_page'))
        elif request.form['action'] == 'updateUser':

            email=request.form['inputEmail']
            password=request.form['inputPassword']
            hashed = pwd_context.encrypt(password)

            execute=[]

            query="""UPDATE USERS SET """


            if len(email)!=0:
                current_user.email=email
                execute+=[str(email)]
                query+="""MAIL=%s"""

            if len(password)!=0:
                current_user.password=hashed
                execute+=[str(hashed)]
                if  len(email)!=0:
                    query+=""", """
                query+="""PASSWORD=%s"""
            if  len(email)==0 and len(password)==0:
                return render_template('settings.html')
            username=current_user.userName

            query+=""" WHERE (USERNAME=%s)"""

            execute+=[username]

            with dbapi2.connect(app.config['dsn']) as connection:
                cursor = connection.cursor()

                cursor.execute(query, execute)

                connection.commit()
            return render_template('settings.html')
    else:
        return render_template('settings.html')
Ejemplo n.º 12
0
def settings_page():
    if request.method == 'POST':
        if request.form['action'] == 'deleteUser':
            with dbapi2.connect(app.config['dsn']) as connection:
                cursor = connection.cursor()

                query = """DELETE FROM USERS WHERE ( USERNAME=%s )"""
                cursor.execute(query, ([current_user.userName]))

                connection.commit()
            logout_user()
            return redirect(url_for('home_page'))
        elif request.form['action'] == 'updateUser':

            email = request.form['inputEmail']
            password = request.form['inputPassword']
            hashed = pwd_context.encrypt(password)

            execute = []

            query = """UPDATE USERS SET """

            if len(email) != 0:
                current_user.email = email
                execute += [str(email)]
                query += """MAIL=%s"""

            if len(password) != 0:
                current_user.password = hashed
                execute += [str(hashed)]
                if len(email) != 0:
                    query += """, """
                query += """PASSWORD=%s"""
            if len(email) == 0 and len(password) == 0:
                return render_template('settings.html')
            username = current_user.userName

            query += """ WHERE (USERNAME=%s)"""

            execute += [username]

            with dbapi2.connect(app.config['dsn']) as connection:
                cursor = connection.cursor()

                cursor.execute(query, execute)

                connection.commit()
            return render_template('settings.html')
    else:
        return render_template('settings.html')
Ejemplo n.º 13
0
def confirm(token):
    content = Crypto().decrypt(token)
    print(content)
    email = content['email']
    user = User().get_user(email=email)
    login_user(user)
    if user is not None and user.confirm(user):
        flash('已经完成了邮箱确认')
        login_user(user)
        return redirect(url_for('main.index'))
    else:
        try:
            logout_user()
        finally:
            flash('邮箱确认错误或已经超过期限')
    return redirect(url_for('main.index'))
Ejemplo n.º 14
0
def login():
    form = LoginForm()
    if request.method == 'POST':
        if current_user.get_id() is not None:
            flash('You are already logged in !')
            return render_template("home.html", title="Login", form=form)

        mail = form.email.data
        password = form.password.data
        new_user = User.get_with_email(mail)
        if new_user and bcrypt.check_password_hash(new_user.password,
                                                   password):
            login_user(new_user)
            flash(f'Logged in successfuly!', 'success ')
            posts = MyProfile(current_user.username)
            return redirect(url_for('home_page'))
        else:
            flash('Email or password incorrect')
            return render_template("login.html", title="Login", form=form)
    else:
        if current_user.get_id() is not None:
            logout_user()
        return render_template('login.html', title="Login", form=form)
Ejemplo n.º 15
0
def logout():
    # Delete credentials if user is authenticated with Google
    if session.get('credentials'):
        # Revoke access if the credentials have not expired
        #credentials = OAuth2Credentials.from_json(session['credentials'])
        #if not credentials.access_token_expired:
        #    try:
        #        credentials.revoke(httplib2.Http())
        #    except TokenRevokeError as e:
        #        print(repr(e))
        #        flash("Could not log out of google.", "danger")
        #        return redirect(url_for('home'))
        del session['credentials']

    # Delete credentials if user is authenticated with Facebook
    if session.get('fb_credentials'):
        del session['fb_credentials']

    logout_user()
    identity_changed.send(current_app._get_current_object(),
                          identity=AnonymousIdentity())

    flash("You have been logged out.", "success")
    return redirect(url_for('home'))
Ejemplo n.º 16
0
def logout():
    try:
        logout_user()
        return redirect('/')
    except BaseException as a:
        return redirect("/login")
Ejemplo n.º 17
0
def logout():
    logout_user()
    flash('You are now logged out', 'success')
    return redirect(url_for('main.index'))
Ejemplo n.º 18
0
def logout():
    logout_user()
    return redirect(url_for("main.homepage"))
Ejemplo n.º 19
0
def logout_page():
    logout_user()
    return redirect(url_for('home_page'))
Ejemplo n.º 20
0
def logout():
    logout_user()
    flash('退出登陆')
    return redirect(url_for('main.index'))
Ejemplo n.º 21
0
def auth_logout():
    logout_user()
    return redirect(url_for("home"))
Ejemplo n.º 22
0
 def logout_view(self):
     logout_user()
     return redirect(url_for(".index"))
Ejemplo n.º 23
0
def logout():
    current_app.logger.info(f"User {current_user.name} logged out")
    logout_user()
    return redirect(url_for("main.main"))
Ejemplo n.º 24
0
def logout():
    logout_user()
    return redirect(url_for('auth_bp.login'))
Ejemplo n.º 25
0
Archivo: app.py Proyecto: osiryz/tip1
def logout():
    logout_user()
    return redirect(url_for("index"))
Ejemplo n.º 26
0
def do_logout():
    logout_user()
    return redirect("/infolist/login")
Ejemplo n.º 27
0
def logout_page():
    logout_user()
    return redirect(url_for('home_page'))
Ejemplo n.º 28
0
def logout():
    logout_user()
    flash('Você saiu da sua conta.', 'success')
    return redirect(url_for('accounts.login'))
Ejemplo n.º 29
0
def logout():
    logout_user()
    flash('You have been logged out.')
    return redirect(url_for('main.index'))
Ejemplo n.º 30
0
def logout():
    logout_user()
    return redirect(url_for('renderHome'))
Ejemplo n.º 31
0
def logout():
    logout_user()
    return redirect(url_for('index'))
Ejemplo n.º 32
0
def logout():
    logout_user()
    flash("Successfully logged out.")
    return redirect(url_for('login'))