@@ -142,6 +142,7 @@ public struct User: Codable, Hashable, Identifiable, Sendable {
142142 public var role : String ?
143143 public var updatedAt : Date
144144 public var identities : [ UserIdentity ] ?
145+ public var isAnonymous : Bool
145146 public var factors : [ Factor ] ?
146147
147148 public init (
@@ -165,6 +166,7 @@ public struct User: Codable, Hashable, Identifiable, Sendable {
165166 role: String ? = nil ,
166167 updatedAt: Date ,
167168 identities: [ UserIdentity ] ? = nil ,
169+ isAnonymous: Bool = false ,
168170 factors: [ Factor ] ? = nil
169171 ) {
170172 self . id = id
@@ -187,8 +189,35 @@ public struct User: Codable, Hashable, Identifiable, Sendable {
187189 self . role = role
188190 self . updatedAt = updatedAt
189191 self . identities = identities
192+ self . isAnonymous = isAnonymous
190193 self . factors = factors
191194 }
195+
196+ public init ( from decoder: any Decoder ) throws {
197+ let container = try decoder. container ( keyedBy: CodingKeys . self)
198+ id = try container. decode ( UUID . self, forKey: . id)
199+ appMetadata = try container. decode ( [ String : AnyJSON ] . self, forKey: . appMetadata)
200+ userMetadata = try container. decode ( [ String : AnyJSON ] . self, forKey: . userMetadata)
201+ aud = try container. decode ( String . self, forKey: . aud)
202+ confirmationSentAt = try container. decodeIfPresent ( Date . self, forKey: . confirmationSentAt)
203+ recoverySentAt = try container. decodeIfPresent ( Date . self, forKey: . recoverySentAt)
204+ emailChangeSentAt = try container. decodeIfPresent ( Date . self, forKey: . emailChangeSentAt)
205+ newEmail = try container. decodeIfPresent ( String . self, forKey: . newEmail)
206+ invitedAt = try container. decodeIfPresent ( Date . self, forKey: . invitedAt)
207+ actionLink = try container. decodeIfPresent ( String . self, forKey: . actionLink)
208+ email = try container. decodeIfPresent ( String . self, forKey: . email)
209+ phone = try container. decodeIfPresent ( String . self, forKey: . phone)
210+ createdAt = try container. decode ( Date . self, forKey: . createdAt)
211+ confirmedAt = try container. decodeIfPresent ( Date . self, forKey: . confirmedAt)
212+ emailConfirmedAt = try container. decodeIfPresent ( Date . self, forKey: . emailConfirmedAt)
213+ phoneConfirmedAt = try container. decodeIfPresent ( Date . self, forKey: . phoneConfirmedAt)
214+ lastSignInAt = try container. decodeIfPresent ( Date . self, forKey: . lastSignInAt)
215+ role = try container. decodeIfPresent ( String . self, forKey: . role)
216+ updatedAt = try container. decode ( Date . self, forKey: . updatedAt)
217+ identities = try container. decodeIfPresent ( [ UserIdentity ] . self, forKey: . identities)
218+ isAnonymous = try container. decodeIfPresent ( Bool . self, forKey: . isAnonymous) ?? false
219+ factors = try container. decodeIfPresent ( [ Factor ] . self, forKey: . factors)
220+ }
192221}
193222
194223public struct UserIdentity : Codable , Hashable , Identifiable , Sendable {
0 commit comments