Esempio n. 1
0
File: app.py Progetto: CMGS/neptulon
 def init_global_vars():
     g.user = None
     if 'id' in session:
         g.user = User.get(session['id'])
     g.redir = request.args.get('redirect', '')
     g.start = request.args.get('start', type=int, default=0)
     g.limit = request.args.get('limit', type=int, default=20)
Esempio n. 2
0
def sudo():
    user_id = request.form['user_id']
    user = User.get(user_id)
    if not user:
        return jsonify({'message': 'not found'}), 404

    user.sudo()
    return jsonify({'message': 'ok'}), 200
Esempio n. 3
0
def get_user(user_id):
    u = User.get(user_id)
    if not u:
        return {}, 404

    user = request.oauth.user
    private = bool(user.privilege) or user.id == user_id
    return u.to_dict(private=private), 200
Esempio n. 4
0
def delete_user():
    user_id = request.form['user_id']
    user = User.get(user_id)
    if not user:
        return jsonify({'message': 'not found'}), 404

    pubkey = RSAKey.get_by_user_id(user_id)
    if pubkey:
        pubkey.delete()
    user.delete()

    return jsonify({'message': 'ok'}), 200
Esempio n. 5
0
def edit(uid):
    u = User.get(uid)
    if not u:
        abort(403)

    if request.method == 'GET':
        return render_template('/admin_edit.html', user=u)

    name = request.form['name']
    email = request.form['email']
    password = request.form['password']
    real_name = request.form['real_name']

    if not (name and email and real_name):
        flash(u'你有些忘记填了', 'error')
        return render_template('/admin_edit.html', user=u.id)

    u.edit(name, email, password, real_name)
    return redirect(url_for('admin.index'))