|
| 1 | +package es.wokis.data.bo.user |
| 2 | + |
| 3 | +import es.wokis.data.constants.ServerConstants.DEFAULT_LANG |
| 4 | +import es.wokis.data.constants.ServerConstants.EMPTY_TEXT |
| 5 | +import io.ktor.server.auth.* |
| 6 | +import java.util.* |
| 7 | + |
| 8 | +data class UserBO( |
| 9 | + val id: String? = null, |
| 10 | + val username: String, |
| 11 | + val email: String, |
| 12 | + val password: String, |
| 13 | + val image: String = EMPTY_TEXT, |
| 14 | + val lang: String = DEFAULT_LANG, |
| 15 | + val createdOn: Long = Date().time, |
| 16 | + val totpEncodedSecret: ByteArray? = null, |
| 17 | + val currentSession: String? = null, |
| 18 | + val emailVerified: Boolean = false, |
| 19 | + val loginWithGoogle: Boolean = false, |
| 20 | + val sessions: List<String> = emptyList(), |
| 21 | + val badges: List<BadgeBO> = emptyList(), |
| 22 | + val devices: List<String> = emptyList(), |
| 23 | + val recoverWords: List<String> = emptyList() |
| 24 | +) : Principal { |
| 25 | + |
| 26 | + override fun equals(other: Any?): Boolean { |
| 27 | + if (this === other) return true |
| 28 | + if (javaClass != other?.javaClass) return false |
| 29 | + |
| 30 | + other as UserBO |
| 31 | + |
| 32 | + if (id != other.id) return false |
| 33 | + if (username != other.username) return false |
| 34 | + if (email != other.email) return false |
| 35 | + if (password != other.password) return false |
| 36 | + if (image != other.image) return false |
| 37 | + if (lang != other.lang) return false |
| 38 | + if (createdOn != other.createdOn) return false |
| 39 | + if (totpEncodedSecret != null) { |
| 40 | + if (other.totpEncodedSecret == null) return false |
| 41 | + if (!totpEncodedSecret.contentEquals(other.totpEncodedSecret)) return false |
| 42 | + } else if (other.totpEncodedSecret != null) return false |
| 43 | + if (emailVerified != other.emailVerified) return false |
| 44 | + if (sessions != other.sessions) return false |
| 45 | + if (badges != other.badges) return false |
| 46 | + if (devices != other.devices) return false |
| 47 | + |
| 48 | + return true |
| 49 | + } |
| 50 | + |
| 51 | + override fun hashCode(): Int { |
| 52 | + var result = id?.hashCode() ?: 0 |
| 53 | + result = 31 * result + username.hashCode() |
| 54 | + result = 31 * result + email.hashCode() |
| 55 | + result = 31 * result + password.hashCode() |
| 56 | + result = 31 * result + image.hashCode() |
| 57 | + result = 31 * result + lang.hashCode() |
| 58 | + result = 31 * result + createdOn.hashCode() |
| 59 | + result = 31 * result + (totpEncodedSecret?.contentHashCode() ?: 0) |
| 60 | + result = 31 * result + emailVerified.hashCode() |
| 61 | + result = 31 * result + sessions.hashCode() |
| 62 | + result = 31 * result + badges.hashCode() |
| 63 | + result = 31 * result + devices.hashCode() |
| 64 | + return result |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +data class BadgeBO( |
| 69 | + val id: Int, |
| 70 | + val color: String |
| 71 | +) |
0 commit comments