diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-05-27 01:03:57 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-05-27 01:03:57 +0200 |
commit | 656e823d91301f637feff2edea3920d3625b43c2 (patch) | |
tree | c70df8f4e3ea16c7a8cf6b31ab2865e190bf43e4 | |
parent | e060b64cae48837b7db1c42d1cd337ff2e08e18b (diff) | |
download | kvision-656e823d91301f637feff2edea3920d3625b43c2.tar.gz kvision-656e823d91301f637feff2edea3920d3625b43c2.tar.bz2 kvision-656e823d91301f637feff2edea3920d3625b43c2.zip |
Refactor of Profile class.
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt | 87 |
1 files changed, 79 insertions, 8 deletions
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<String, String> = mutableMapOf(), + val authenticationAttributes: MutableMap<String, String> = mutableMapOf(), + val roles: MutableSet<String> = mutableSetOf(), + val permissions: MutableSet<String> = 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") + } + } +} |