remove locationgroup
This commit is contained in:
parent
2ee82a2eed
commit
68107ca7f0
@ -86,13 +86,13 @@ object Auth {
|
|||||||
//sync plant's from rmc to here, just name and id
|
//sync plant's from rmc to here, just name and id
|
||||||
for (plantId in plantIds) {
|
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 ->
|
h.execute(HttpGet("${appConfig.integrationRmc()}/plant?id=${plantId}")).use { r ->
|
||||||
if (r.statusLine.statusCode == 200) {
|
if (r.statusLine.statusCode == 200) {
|
||||||
val response = EntityUtils.toString(r.entity)
|
val response = EntityUtils.toString(r.entity)
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
Session.database.save(Plant().apply {
|
database.save(Plant().apply {
|
||||||
this.plantId = plantId
|
this.plantId = plantId
|
||||||
this.plantName = response
|
this.plantName = response
|
||||||
})
|
})
|
||||||
@ -112,7 +112,7 @@ object Auth {
|
|||||||
|
|
||||||
return AuthUser(
|
return AuthUser(
|
||||||
userName = userId,
|
userName = userId,
|
||||||
tenant = getTenantWithCompany(userId, tenant),
|
tenant = tenant,
|
||||||
roles = roles,
|
roles = roles,
|
||||||
token = authToken,
|
token = authToken,
|
||||||
expiry = LocalDateTime.from(date.toInstant().atZone(ZoneId.systemDefault())),
|
expiry = LocalDateTime.from(date.toInstant().atZone(ZoneId.systemDefault())),
|
||||||
@ -121,26 +121,6 @@ object Auth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val userToTenant = ConcurrentHashMap<String, String>()
|
private val userToTenant = ConcurrentHashMap<String, String>()
|
||||||
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) {
|
fun keys(ctx: Context) {
|
||||||
ctx.json(Session.jwk())
|
ctx.json(Session.jwk())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user