17
17
# 'src/freeauth/users/queries/get_user_by_id.edgeql'
18
18
# 'src/freeauth/organizations/queries/organization_add_member.edgeql'
19
19
# 'src/freeauth/organizations/queries/query_org_types.edgeql'
20
+ # 'src/freeauth/users/queries/resign_user.edgeql'
20
21
# 'src/freeauth/auth/queries/send_code.edgeql'
21
22
# 'src/freeauth/auth/queries/sign_in.edgeql'
22
23
# 'src/freeauth/auth/queries/sign_up.edgeql'
25
26
# 'src/freeauth/organizations/queries/update_org_type.edgeql'
26
27
# 'src/freeauth/organizations/queries/update_org_type_status.edgeql'
27
28
# 'src/freeauth/users/queries/update_user.edgeql'
29
+ # 'src/freeauth/users/queries/update_user_organization.edgeql'
28
30
# 'src/freeauth/users/queries/update_user_status.edgeql'
29
31
# 'src/freeauth/settings/queries/upsert_login_setting.edgeql'
30
32
# 'src/freeauth/auth/queries/validate_code.edgeql'
@@ -807,6 +809,25 @@ async def query_org_types(
807
809
)
808
810
809
811
812
+ async def resign_user (
813
+ executor : edgedb .AsyncIOExecutor ,
814
+ * ,
815
+ user_ids : list [uuid .UUID ],
816
+ ) -> list [DeleteUserResult ]:
817
+ return await executor .query (
818
+ """\
819
+ SELECT (
820
+ UPDATE User FILTER .id in array_unpack(<array<uuid>>$user_ids)
821
+ SET {
822
+ directly_organizations := {},
823
+ deleted_at := datetime_of_transaction()
824
+ }
825
+ ) { name } ORDER BY .created_at DESC;\
826
+ """ ,
827
+ user_ids = user_ids ,
828
+ )
829
+
830
+
810
831
async def send_code (
811
832
executor : edgedb .AsyncIOExecutor ,
812
833
* ,
@@ -1210,7 +1231,6 @@ async def update_user(
1210
1231
username : str | None ,
1211
1232
email : str | None ,
1212
1233
mobile : str | None ,
1213
- organization_ids : list [uuid .UUID ] | None ,
1214
1234
id : uuid .UUID ,
1215
1235
) -> CreateUserResult | None :
1216
1236
return await executor .query_single (
@@ -1219,19 +1239,14 @@ async def update_user(
1219
1239
name := <optional str>$name,
1220
1240
username := <optional str>$username,
1221
1241
email := <optional str>$email,
1222
- mobile := <optional str>$mobile,
1223
- organization_ids := <optional array<uuid>>$organization_ids
1242
+ mobile := <optional str>$mobile
1224
1243
SELECT (
1225
1244
UPDATE User FILTER .id = <uuid>$id
1226
1245
SET {
1227
1246
name := name,
1228
1247
username := username,
1229
1248
email := email,
1230
- mobile := mobile,
1231
- directly_organizations := (
1232
- SELECT Organization
1233
- FILTER .id IN array_unpack(organization_ids)
1234
- )
1249
+ mobile := mobile
1235
1250
}
1236
1251
) {
1237
1252
name,
@@ -1250,11 +1265,44 @@ async def update_user(
1250
1265
username = username ,
1251
1266
email = email ,
1252
1267
mobile = mobile ,
1253
- organization_ids = organization_ids ,
1254
1268
id = id ,
1255
1269
)
1256
1270
1257
1271
1272
+ async def update_user_organization (
1273
+ executor : edgedb .AsyncIOExecutor ,
1274
+ * ,
1275
+ id : uuid .UUID ,
1276
+ organization_ids : list [uuid .UUID ],
1277
+ ) -> CreateUserResult | None :
1278
+ return await executor .query_single (
1279
+ """\
1280
+ SELECT (
1281
+ UPDATE User FILTER .id = <uuid>$id
1282
+ SET {
1283
+ directly_organizations := (
1284
+ SELECT Organization
1285
+ FILTER .id IN array_unpack(<array<uuid>>$organization_ids)
1286
+ )
1287
+ }
1288
+ ) {
1289
+ name,
1290
+ username,
1291
+ email,
1292
+ mobile,
1293
+ departments := (
1294
+ SELECT .directly_organizations { code, name }
1295
+ ),
1296
+ is_deleted,
1297
+ created_at,
1298
+ last_login_at
1299
+ };\
1300
+ """ ,
1301
+ id = id ,
1302
+ organization_ids = organization_ids ,
1303
+ )
1304
+
1305
+
1258
1306
async def update_user_status (
1259
1307
executor : edgedb .AsyncIOExecutor ,
1260
1308
* ,
0 commit comments