Exemple #1
0
def oauth_manager_clients():
    validateUsers(['root'])
    from vinos_core import manager_clients
    response = manager_clients()
    if response.status_code == 201:
        username = request.json.get('email', "")
        setClient(getUserbyName(username))
    return response
def oauth_manager_clients():
    validateUsers(['root'])
    from vinos_core import manager_clients
    response = manager_clients()
    if response.status_code == 201:
        username = request.json.get('email', "")
        setClient(getUserbyName(username))
    return response
Exemple #3
0
def authorize(*args, **kwargs):
    if request.method == 'GET':
        # print kwargs
        return render_template('logIn.html', **kwargs)
    else:
        username = request.form.get('username')
        passwd = request.form.get('passwd')
        user = getUserbyName(username)
        if user and user.passwd == passwd:
            session['id'] = user.id
            return True
        return False
def authorize(*args, **kwargs):
    if request.method == 'GET':
        # print kwargs
        return render_template('logIn.html', **kwargs)
    else:
        username = request.form.get('username')
        passwd = request.form.get('passwd')
        user = getUserbyName(username)
        if user and user.passwd == passwd:
            session['id'] = user.id
            return True
        return False
Exemple #5
0
@app.route('/logout', methods=['GET'])
@oauth.require_oauth()
def logOut():
    user = request.oauth.user
    session.pop('id', None)
    return make_response(jsonify({"LogedOut": user.username}), 200)


@app.route('/me')
@oauth.require_oauth()
def me():
    return jsonify(username=request.oauth.user.username)


if __name__ == '__main__':
    db.create_all()
    # Got root?
    if not getUserbyName('root'):
        root = User(username='******', passwd='root', id=1)
        client = Client(
            client_id='SjHWna6K40tQdqyVAxEDjR5EGpbLM741oOWJRSz0',
            client_secret='n7T1j51NOFn3ARfrsFOnCrblDUBnPz2yIKcQ5VhSMye3W1YK01',
            _redirect_uris='http://127.0.0.1:8000/authorized',
            _default_scopes='email',
            user_id=1,
        )
        db.session.add(root)
        db.session.add(client)
        db.session.commit()
    app.run(debug=True)
@app.route('/logout', methods=['GET'])
@oauth.require_oauth()
def logOut():
    user = request.oauth.user
    session.pop('id', None)
    return make_response(jsonify({"LogedOut": user.username}), 200)


@app.route('/me')
@oauth.require_oauth()
def me():
    return jsonify(username=request.oauth.user.username)


if __name__ == '__main__':
    db.create_all()
    # Got root?
    if not getUserbyName('root'):
        root = User(username='******', passwd='root', id=1)
        client = Client(
            client_id='SjHWna6K40tQdqyVAxEDjR5EGpbLM741oOWJRSz0',
            client_secret='n7T1j51NOFn3ARfrsFOnCrblDUBnPz2yIKcQ5VhSMye3W1YK01',
            _redirect_uris='http://127.0.0.1:8000/authorized',
            _default_scopes='email',
            user_id=1,
        )
        db.session.add(root)
        db.session.add(client)
        db.session.commit()
    app.run(debug=True)