From 68107ca7f03ac752f5d12875fbbcca2cf5b9fa9f Mon Sep 17 00:00:00 2001 From: gowthaman Date: Tue, 11 Jun 2024 08:28:53 +0530 Subject: [PATCH] remove locationgroup --- src/main/kotlin/com/restapi/config/Auth.kt | 26 +++------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/main/kotlin/com/restapi/config/Auth.kt b/src/main/kotlin/com/restapi/config/Auth.kt index 9175412..0d3bce1 100644 --- a/src/main/kotlin/com/restapi/config/Auth.kt +++ b/src/main/kotlin/com/restapi/config/Auth.kt @@ -86,13 +86,13 @@ object Auth { //sync plant's from rmc to here, just name and id for (plantId in plantIds) { - val existing = Session.database.find(Plant::class.java).where().eq("plantId", plantId).findOne() + val existing = database.find(Plant::class.java).where().eq("plantId", plantId).findOne() h.execute(HttpGet("${appConfig.integrationRmc()}/plant?id=${plantId}")).use { r -> if (r.statusLine.statusCode == 200) { val response = EntityUtils.toString(r.entity) if (existing == null) { - Session.database.save(Plant().apply { + database.save(Plant().apply { this.plantId = plantId this.plantName = response }) @@ -112,7 +112,7 @@ object Auth { return AuthUser( userName = userId, - tenant = getTenantWithCompany(userId, tenant), + tenant = tenant, roles = roles, token = authToken, expiry = LocalDateTime.from(date.toInstant().atZone(ZoneId.systemDefault())), @@ -121,26 +121,6 @@ object Auth { } private val userToTenant = ConcurrentHashMap() - private fun getTenantWithCompany(userId: String, tenant: String): String { - return userToTenant.computeIfAbsent(userId) { - try { - HttpClients.createDefault().use { h -> - //sync plant's from rmc to here, just name and id - - h.execute(HttpGet("${appConfig.integrationRmc()}/tenant?id=${userId}")).use { r -> - if (r.statusLine.statusCode == 200) { - - "$tenant${EntityUtils.toString(r.entity)}" - } - - } - } - } catch (e: Exception) { - logger.warn("Exception in syncing plants", e) - } - tenant - } - } fun keys(ctx: Context) { ctx.json(Session.jwk())