Esempio n. 1
0
def setUid(req, uid, remember_me=False):
    """It sets the userId into the session, and raise the cookie to the client.
    """
    if uid > 0:
        login_user(uid, remember_me)
    else:
        logout_user()
    return uid
Esempio n. 2
0
def setUid(req, uid, remember_me=False):
    """It sets the userId into the session, and raise the cookie to the client.
    """
    if uid > 0:
        login_user(uid, remember_me)
    else:
        logout_user()
    return uid
Esempio n. 3
0
def logout():
    logout_user()

    from invenio.modules.access.local_config import \
        CFG_EXTERNAL_AUTH_USING_SSO, \
        CFG_EXTERNAL_AUTH_LOGOUT_SSO

    if CFG_EXTERNAL_AUTH_USING_SSO:
        return redirect(CFG_EXTERNAL_AUTH_LOGOUT_SSO)

    return render_template('accounts/logout.html',
                           using_sso=CFG_EXTERNAL_AUTH_USING_SSO,
                           logout_sso=CFG_EXTERNAL_AUTH_LOGOUT_SSO)
Esempio n. 4
0
def logout():
    logout_user()

    from invenio.modules.access.local_config import \
        CFG_EXTERNAL_AUTH_USING_SSO, \
        CFG_EXTERNAL_AUTH_LOGOUT_SSO

    if CFG_EXTERNAL_AUTH_USING_SSO:
        return redirect(CFG_EXTERNAL_AUTH_LOGOUT_SSO)

    return render_template('accounts/logout.html',
                           using_sso=CFG_EXTERNAL_AUTH_USING_SSO,
                           logout_sso=CFG_EXTERNAL_AUTH_LOGOUT_SSO)
Esempio n. 5
0
    def action_become_user(self, ids):
        """Inactivate users."""
        try:
            if len(ids) != 1:
                flash('You can only become one user at a time.', '')
            user = User.query.get(ids[0])
            logout_user()
            login_user(user)
        except Exception as ex:
            if not self.handle_view_exception(ex):
                raise

            flash('Failed to become users. %(error)s' % dict(error=str(ex)),
                  'error')
Esempio n. 6
0
    def test_low_level_login(data, self):
        users = data.UserData

        assert current_user.is_guest
        login_user(users.admin.id)
        assert current_user.get_id() == users.admin.id
        logout_user()
        assert current_user.get_id() != users.admin.id
        assert current_user.is_guest
        login_user(users.romeo.id)
        assert not current_user.is_guest
        assert current_user.get_id() == users.romeo.id
        login_user(users.admin.id)
        assert current_user.get_id() == users.admin.id
        logout_user()
Esempio n. 7
0
    def test_low_level_login(data, self):
        users = data.UserData

        assert current_user.is_guest
        login_user(users.admin.id)
        assert current_user.get_id() == users.admin.id
        logout_user()
        assert current_user.get_id() != users.admin.id
        assert current_user.is_guest
        login_user(users.romeo.id)
        assert not current_user.is_guest
        assert current_user.get_id() == users.romeo.id
        login_user(users.admin.id)
        assert current_user.get_id() == users.admin.id
        logout_user()
Esempio n. 8
0
def upload(service, src, dest, user=None):
    """Upload a file."""
    from invenio.ext.login import login_user, logout_user
    from invenio.ext.sqlalchemy import db

    from invenio_accounts.models import User
    from invenio.modules.cloudconnector import utils
    from invenio_oauthclient.views.client import setup_app

    # Get user instance
    user = User.query.filter(db.or_(
        User.nickname == user,
        User.email == user,
        User.id == user)).one()

    login_user(user.id)
    setup_app()
    utils.upload(service, src, dest)
    logout_user()
Esempio n. 9
0
def logoutUser(req):
    """It logout the user of the system, creating a guest user.
    """
    from invenio.ext.login import logout_user
    logout_user()
    return current_user.get_id()