forked from SteamWar/SteamWar
Backend Fixes
This commit is contained in:
@@ -45,7 +45,7 @@ data class ResponseSchematicType(val name: String, val db: String)
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ResponseUser(val name: String, val uuid: String, val prefix: String, val perms: List<String>) {
|
data class ResponseUser(val name: String, val uuid: String, val prefix: String, val perms: List<String>) {
|
||||||
constructor(user: SteamwarUser) : this(user.userName, user.uuid.toString(), user.prefix().chatPrefix, user.perms().map { it.name }) {
|
constructor(user: SteamwarUser) : this(user.userName, user.uuid.toString(), user.prefix().chatPrefix, user.perms().filter { !it.name.startsWith("PREFIX_") }.map { it.name }) {
|
||||||
synchronized(cache) {
|
synchronized(cache) {
|
||||||
cache[user.id] = this
|
cache[user.id] = this
|
||||||
}
|
}
|
||||||
@@ -149,5 +149,6 @@ fun Route.configureDataRoutes() {
|
|||||||
inline fun <T> catchException(yield: () -> T): T? = try {
|
inline fun <T> catchException(yield: () -> T): T? = try {
|
||||||
yield()
|
yield()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ fun Route.configureEventsRoute() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.update(eventName, deadline, start, end, schemType, maxTeamMembers, publicSchemsOnly)
|
event.update(eventName, deadline, start, end, schemType, maxTeamMembers, publicSchemsOnly)
|
||||||
call.respond(ResponseEvent(event))
|
call.respond(ResponseEvent(Event.get(event.eventID)))
|
||||||
}
|
}
|
||||||
delete {
|
delete {
|
||||||
val id = call.parameters["id"]?.toIntOrNull()
|
val id = call.parameters["id"]?.toIntOrNull()
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ fun Route.configureUserPerms() {
|
|||||||
call.respond(RespondUserPermsPrefix(RespondPrefix(prefix.name, prefixs.colorCode, prefixs.chatPrefix), perms))
|
call.respond(RespondUserPermsPrefix(RespondPrefix(prefix.name, prefixs.colorCode, prefixs.chatPrefix), perms))
|
||||||
}
|
}
|
||||||
put("/prefix/{prefix}") {
|
put("/prefix/{prefix}") {
|
||||||
val (user, prefix) = call.receivePermission("prefix") ?: return@put
|
val (user, prefix) = call.receivePermission("prefix", isPrefix = true) ?: return@put
|
||||||
|
|
||||||
user.perms().filter { it.name.startsWith("PREFIX_") }.forEach {
|
user.perms().filter { it.name.startsWith("PREFIX_") }.forEach {
|
||||||
UserPerm.removePerm(user, it)
|
UserPerm.removePerm(user, it)
|
||||||
@@ -121,7 +121,8 @@ suspend fun ApplicationCall.receivePermission(fieldName: String = "perm", isPref
|
|||||||
|
|
||||||
val perm = parameters[fieldName]
|
val perm = parameters[fieldName]
|
||||||
val permission = UserPerm.entries.find { it.name == perm }
|
val permission = UserPerm.entries.find { it.name == perm }
|
||||||
if (perm == null || perm.startsWith("PREFIX_") == isPrefix || permission == null) {
|
if (perm == null || perm.startsWith("PREFIX_") != isPrefix || permission == null) {
|
||||||
|
println(perm)
|
||||||
respond(HttpStatusCode.BadRequest)
|
respond(HttpStatusCode.BadRequest)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user