예제 #1
0
def purge():
    '''
    Truncate all tables
    '''
    Users.delete().execute()
    Inventory.delete().execute()
    AccessRights.delete().execute()
    Credentials.delete().execute()
예제 #2
0
    def get(self, *args, **kwargs):
        # 从数据库中提取数据
        # users = Users.all()
        # self.render('user.html', users=users)

        # 增加数据
        # user = Users('hello','world')
        # user.save()

        # 删除数据

        user = Users('hello', 'world')
        user.delete()
        self.write('ok')
예제 #3
0
파일: users.py 프로젝트: masom/Puck
    def delete(self, id):
        jail = Users.first(id=id)
        msg = "The user could not be deleted."
        if jail:
            if Users.delete(jail):
                msg = "User deleted."

        cherrypy.session['flash'] = msg
        raise cherrypy.HTTPRedirect('/users')
예제 #4
0
    def delete_user(valid, user_id):
        if valid:
            data = Users.query.get(user_id)

            if data:
                name = data.name
                try:
                    Users.delete(data)
                except Exception as e:
                    abort(404, e)
            else:
                abort(
                    make_response(jsonify({'message': 'User does not exist'}),
                                  404))

            result = {"success": True, "message": name + ' has been deleted'}
            return jsonify(result)
        else:
            abort(401)
예제 #5
0
def delete():
    # credit: Yam Mesicka
    # https://youtu.be/nl1R7MV8jB0
    if request.method == 'GET':
        return render_template('login.j2')

    user_name = request.form['user_name']
    if user_name is None:
        return abort(400, 'No user_name supplied')

    try:
        user = Users.select().where(Users.user_name == user_name).get()
    except peewee.DoesNotExist:
        return abort(404, f'User {user_name} does not exists')

    password = request.form['password'].encode('utf-8')
    real_password = str(user.password).encode('utf-8')
    if not bcrypt.checkpw(password, real_password):
        return abort(403, 'user_name and password does not match')
    Users.delete().where(Users.user_name == user_name).execute()
    for session_value in ('user_name', 'level', 'game', 'game_resulte',
                          'riddle'):
        session.pop(session_value, None)
    return redirect(url_for('register'))