From 656e823d91301f637feff2edea3920d3625b43c2 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 27 May 2018 01:03:57 +0200 Subject: Refactor of Profile class. --- .../kotlin/pl/treksoft/kvision/remote/Jooby.kt | 87 ++++++++++++++++++++-- 1 file changed, 79 insertions(+), 8 deletions(-) (limited to 'src/main/kotlin/pl') diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt b/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt index cd62487a..fcd6b0ab 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt @@ -22,6 +22,7 @@ package pl.treksoft.kvision.remote import kotlinx.serialization.Serializable +import kotlinx.serialization.Transient /** * A Jooby based server. @@ -41,12 +42,82 @@ actual interface Request @Serializable actual data class Profile( val id: String? = null, - val username: String? = null, + val attributes: MutableMap = mutableMapOf(), + val authenticationAttributes: MutableMap = mutableMapOf(), + val roles: MutableSet = mutableSetOf(), + val permissions: MutableSet = mutableSetOf(), val linkedId: String? = null, - val firstName: String? = null, - val familyName: String? = null, - val email: String? = null, - val displayName: String? = null, - val pictureUrl: String? = null, - val profileUrl: String? = null -) + val remembered: Boolean = false, + val clientName: String? = null +) { + @Transient + var username: String? + get() = attributes["username"] + set(value) { + if (value != null) { + attributes["username"] = value + } else { + attributes.remove("username") + } + } + @Transient + var firstName: String? + get() = attributes["first_name"] + set(value) { + if (value != null) { + attributes["first_name"] = value + } else { + attributes.remove("first_name") + } + } + @Transient + var familyName: String? + get() = attributes["family_name"] + set(value) { + if (value != null) { + attributes["family_name"] = value + } else { + attributes.remove("family_name") + } + } + @Transient + var displayName: String? + get() = attributes["display_name"] + set(value) { + if (value != null) { + attributes["display_name"] = value + } else { + attributes.remove("display_name") + } + } + @Transient + var email: String? + get() = attributes["email"] + set(value) { + if (value != null) { + attributes["email"] = value + } else { + attributes.remove("email") + } + } + @Transient + var pictureUrl: String? + get() = attributes["picture_url"] + set(value) { + if (value != null) { + attributes["picture_url"] = value + } else { + attributes.remove("picture_url") + } + } + @Transient + var profileUrl: String? + get() = attributes["profile_url"] + set(value) { + if (value != null) { + attributes["profile_url"] = value + } else { + attributes.remove("profile_url") + } + } +} -- cgit