Ejemplo n.º 1
0
def do_login():
    username = request.form['username']
    pwd = request.form['password']
    origin = request.form.get("origin", None)
    user = User.authenticate(username, pwd)
    Audit.login(username, origin)
    return jsonify(User.to_safe_dict(user)) if user else abort(401)
Ejemplo n.º 2
0
def get_users(*args, **kwargs):
    resultset = []
    docs = User.get_all(*args, **kwargs)
    for doc in docs:
        resultset.append(User.to_safe_dict(doc))

    return jsonify({'resultset': resultset})
Ejemplo n.º 3
0
def new_user():
    username = request.form['username']
    password = request.form['password']
    email = request.form['email']
    device = request.form.get("origin", None)
    doc = User.create(username, password, email, device)
    if 'error' in doc:
        abort(409, 'User already exists')
    else:
        Audit.signup(username, '')
        return jsonify({'user': User.to_safe_dict(doc)})
Ejemplo n.º 4
0
def get_oi_user(username):
    doc = User.get({'$or': [{'username': username.strip()}, {'email': username.strip()}]})
    return jsonify({'user': User.to_safe_dict(doc)})