Esempio n. 1
0
    def logout(self):
        ''' logout from the system
        '''

        result = {'logout': 'success'}

        if 'loginready' in current_session:
            ready = current_session.pop('loginready')

        if 'name' in current_session:
            name = current_session.pop('name')

        request.environ['REMOTE_USER'] = None
        config.access = 'public'
        set_session_versions(config.release)
        setGlobalSession()
        logout_user()

        return redirect(url_for('index_page.Marvin:index'))
Esempio n. 2
0
    def login(self):
        form = processRequest(request=request)
        result = {}
        username = form['username'].strip()
        password = form['password'].strip()

        # do nothing if already validated
        if current_user.is_authenticated:
            return jsonify(result=result)

        # validate the user with htpassfile or trac username
        is_valid, user, result = validate_user(username,
                                               password,
                                               request=request,
                                               session=current_session)

        # get User only if valid
        if is_valid:
            user = get_db_user(username,
                               password,
                               dbsession=marvindb.session,
                               user_model=marvindb.datadb.User,
                               request=request)
            if user and user.check_password(password):
                login_user(user)

        if is_valid:
            result['status'] = 1
            result['message'] = 'Login Successful!'
            current_session['name'] = user.username
            current_session['loginready'] = True
            config.access = 'collab'
            setGlobalSession()
        else:
            result['status'] = -1
            result['message'] = 'Login {0} is not valid!'.format(username)

        return jsonify(result=result)