diff --git a/api/kiwi_vpn_api/db/device.py b/api/kiwi_vpn_api/db/device.py index 46750cd..1b98122 100644 --- a/api/kiwi_vpn_api/db/device.py +++ b/api/kiwi_vpn_api/db/device.py @@ -56,6 +56,9 @@ class Device(DeviceRead, table=True): # might be a future problem? owner: User = Relationship( back_populates="devices", + sa_relationship_kwargs={ + "lazy": "joined", + }, ) @classmethod diff --git a/api/kiwi_vpn_api/easyrsa.py b/api/kiwi_vpn_api/easyrsa.py index 4c082dd..e86e60e 100644 --- a/api/kiwi_vpn_api/easyrsa.py +++ b/api/kiwi_vpn_api/easyrsa.py @@ -301,11 +301,9 @@ if __name__ == "__main__": Connection.connect(current_config.db.uri) if (device := Device.get(1)) is not None: - with Connection.session as db: - db.add(device) - dn = DistinguishedName.build(device) - - client = easy_rsa.issue(dn=dn) + client = easy_rsa.issue( + dn=DistinguishedName.build(device) + ) for cert in (ca, server, client): if cert is not None: