Fix test auth
authorTheSaminator <TheSaminator@users.noreply.github.com>
Thu, 10 Feb 2022 15:59:56 +0000 (10:59 -0500)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Thu, 10 Feb 2022 15:59:56 +0000 (10:59 -0500)
src/jvmMain/kotlin/starshipfights/auth/providers.kt
src/jvmMain/kotlin/starshipfights/data/auth/user_sessions.kt

index 4bc3359f1ba29c0e1581d4daffd900595aa3c992..01a5a46ce4ca8a7adc256e401b27d55908faa088 100644 (file)
@@ -230,9 +230,9 @@ object TestAuthProvider : AuthProvider {
                                                        ?: User(
                                                                discordId = credentials.name,
                                                                discordName = "",
-                                                               discordDiscriminator = "0000",
+                                                               discordDiscriminator = "",
                                                                discordAvatar = null,
-                                                               profileName = "Test User"
+                                                               profileName = credentials.name
                                                        ).also {
                                                                User.put(it)
                                                        }
@@ -275,7 +275,7 @@ object TestAuthProvider : AuthProvider {
                                
                                call.respondHtml(HttpStatusCode.OK, page("Authentication Test", call.standardNavBar(), CustomSidebar {
                                        p {
-                                               +"This instance does not have Discrd OAuth login set up. As a fallback, this authentication mode is used for testing."
+                                               +"This instance does not have Discord OAuth login set up. As a fallback, this authentication mode is used for testing."
                                        }
                                }) {
                                        section {
index 2be729ab7eb87704370fafcee036442b40843496..bc4d7b97ac77322611a52907e9fe87ea169b3d3b 100644 (file)
@@ -24,7 +24,7 @@ data class User(
        val discordAvatarUrl: String
                get() = discordAvatar?.let {
                        "https://cdn.discordapp.com/avatars/$discordId/$it." + (if (it.startsWith("a_")) "gif" else "png") + "?size=256"
-               } ?: "https://cdn.discordapp.com/embed/avatars/${discordDiscriminator.last().digitToInt() % 5}.png"
+               } ?: "https://cdn.discordapp.com/embed/avatars/${(discordDiscriminator.lastOrNull()?.digitToInt() ?: 0) % 5}.png"
        
        companion object Table : DocumentTable<User> by DocumentTable.create({
                unique(User::discordId)