Skip to content

Commit 9a74f63

Browse files
committed
ALL MY PROBLEMS WAS BECAUSE OF RC-1????
1 parent 4677796 commit 9a74f63

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ kaml_version=0.98.0
3030
# https://spark.lucko.me/docs/Developer-API
3131
spark_api_version=0.1-SNAPSHOT
3232
# https://www.jetbrains.com/help/exposed/exposed-modules.html
33-
exposed_version=1.0.0-rc-1
33+
exposed_version=1.0.0-rc-2
3434

3535
# https://www.jetbrains.com/help/exposed/working-with-database.html#r2dbc-h2-db
3636
h2_database_version=1.0.0.RELEASE

src/main/kotlin/ua/pp/lumivoid/iwtcms/ktor/api/doAuth.kt

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,41 @@ suspend fun doAuth(
4040
return HttpStatusCode.Unauthorized
4141
}
4242

43-
val user = suspendTransaction {
44-
UsersTable
43+
val status = suspendTransaction {
44+
val user = UsersTable
4545
.selectAll()
4646
.where { (UsersTable.username eq session.name) and (UsersTable.uniqueId eq session.id) }
4747
.firstOrNull()
48-
}
4948

50-
if (user == null) {
51-
unauthorized()
52-
return HttpStatusCode.Unauthorized
53-
}
49+
if (user == null) {
50+
return@suspendTransaction HttpStatusCode.Unauthorized
51+
}
5452

55-
if (user[UsersTable.admin]) {
56-
success()
57-
return HttpStatusCode.OK
58-
}
53+
if (user[UsersTable.admin]) {
54+
return@suspendTransaction HttpStatusCode.OK
55+
}
5956

60-
val permission: ResultRow =
61-
try {
57+
val permission: ResultRow = try {
6258
UserPermissionsTable
6359
.selectAll()
6460
.where { (UserPermissionsTable.userId eq user[UsersTable.id]) and (UserPermissionsTable.permissionName eq permission) }
6561
.first()
6662
} catch (_: NoSuchElementException) {
67-
forbidden()
68-
return HttpStatusCode.Forbidden
63+
return@suspendTransaction HttpStatusCode.Forbidden
6964
}
7065

71-
if (permission[UserPermissionsTable.permissionState]) {
72-
success()
73-
return HttpStatusCode.OK
74-
} else {
75-
forbidden()
76-
return HttpStatusCode.Forbidden
66+
if (permission[UserPermissionsTable.permissionState]) {
67+
return@suspendTransaction HttpStatusCode.OK
68+
} else {
69+
return@suspendTransaction HttpStatusCode.Forbidden
70+
}
7771
}
72+
73+
when (status) {
74+
HttpStatusCode.Unauthorized -> unauthorized()
75+
HttpStatusCode.Forbidden -> forbidden()
76+
HttpStatusCode.OK -> success()
77+
}
78+
79+
return status
7880
}

0 commit comments

Comments
 (0)