Пример #1
0
def deploy():
    """Run deployment tasks."""
    db.create_all()
    # create or update user roles
    db.session.begin(subtransactions=True)
    Role.insert_roles()
    UserDal.add_user('test', '', '123456', 1)
Пример #2
0
def deploy():
    """Run deployment tasks."""
    # db.drop_all()
    db.create_all()
    # create or update user roles
    db.session.begin(subtransactions=True)
    Role.insert_roles()
    UserDal.add_user('test', '', '123456', 1)
Пример #3
0
def delete_user(username):
    if username == current_user.username:
        raise BadParam('cannot delete yourself')
    user = UserDal.get_user_info(username=username)
    if not user:
        raise BadParam('No such user with name: %s' % username)
    result = user.json_serialize(include=('username', 'email', 'role'))
    UserDal.delete_user(username)
    return result
Пример #4
0
def login():
    if request.method == 'POST':
        form = request.get_json(force=True)
        user = UserDal.get_user_info(username=form['username'])
        if user is not None and user.verify_password(form['password']):
            login_user(user, remember=True)
            return current_user.username
        raise DnsdbException('Invalid username or password.', msg_ch=u'账号或密码错误')
    else:
        raise Unauthorized()
Пример #5
0
def add_user(username, email, password, role_id):
    UserDal.add_user(username, email, password, role_id)
Пример #6
0
def list_user(**kwargs):
    return UserDal.list_user(**kwargs)
Пример #7
0
def get_user(username):
    user = UserDal.get_user_info(username=username)
    if user is None:
        return []
    return [UserDal.get_user_info(username=username).json_serialize()]
Пример #8
0
def get_roles():
    return UserDal.get_roles()
Пример #9
0
def get_update_info(result, **kwargs):
    op_after = kwargs.copy()
    op_after.pop('password', None)
    role_id = op_after.pop('role_id')
    op_after['role'] = UserDal.get_role_name(role_id)
    return kwargs['username'], {}, op_after
Пример #10
0
def list_user(**kwargs):
    print kwargs
    return UserDal.list_user(**kwargs)