Пример #1
0
def create_user(username, password, ifAdmin):
    get_user = User.query.filter_by(username=username).first()
    if get_user:
        return False

    if ifAdmin:
        new_user = User(
            uuid_generator.create_new_uuid(),
            username,
            password,
            "100"
        )
    else:
        new_user = User(
            uuid_generator.create_new_uuid(),
            username,
            password,
            "0"
        )
    db.session.add(new_user)
    db.session.commit()
    flask_login.login_user(new_user)
    new_login_history = LoginHistory(
        uuid_generator.create_new_uuid(),
        new_user.id,
        time_util.get_now()
    )
    db.session.add(new_login_history)
    db.session.commit()
    return True
Пример #2
0
def create_server(server_ip, server_name, server_type, server_user, server_psw, server_ssh):
    new_server = Server(
        uuid_generator.create_new_uuid(),
        server_ip,
        server_name,
        server_type,
        server_user,
        server_psw,
        server_ssh
    )
    db.session.add(new_server)
    db.session.commit()
Пример #3
0
def create_user_nologin(username, password, ifAdmin):
    get_user = User.query.filter_by(username=username).first()
    if get_user:
        return False

    if ifAdmin:
        new_user = User(
            uuid_generator.create_new_uuid(),
            username,
            password,
            "100"
        )
    else:
        new_user = User(
            uuid_generator.create_new_uuid(),
            username,
            password,
            "0"
        )
    db.session.add(new_user)
    db.session.commit()
    return True
Пример #4
0
def login_as_user(username, password):
    get_user = User.query.filter_by(username=username).first()
    if get_user:
        if get_user.password == password:
            flask_login.login_user(get_user)
            new_login_history = LoginHistory(
                uuid_generator.create_new_uuid(),
                get_user.id,
                time_util.get_now()
            )
            db.session.add(new_login_history)
            db.session.commit()
            return True

    return False
Пример #5
0
def create_certification():
    new_c = Certification(uuid_generator.create_new_uuid())
    db.session.add(new_c)
    db.session.commit()