@@ -142,6 +142,7 @@ public struct User: Codable, Hashable, Identifiable, Sendable {
142
142
public var role : String ?
143
143
public var updatedAt : Date
144
144
public var identities : [ UserIdentity ] ?
145
+ public var isAnonymous : Bool
145
146
public var factors : [ Factor ] ?
146
147
147
148
public init (
@@ -165,6 +166,7 @@ public struct User: Codable, Hashable, Identifiable, Sendable {
165
166
role: String ? = nil ,
166
167
updatedAt: Date ,
167
168
identities: [ UserIdentity ] ? = nil ,
169
+ isAnonymous: Bool = false ,
168
170
factors: [ Factor ] ? = nil
169
171
) {
170
172
self . id = id
@@ -187,8 +189,35 @@ public struct User: Codable, Hashable, Identifiable, Sendable {
187
189
self . role = role
188
190
self . updatedAt = updatedAt
189
191
self . identities = identities
192
+ self . isAnonymous = isAnonymous
190
193
self . factors = factors
191
194
}
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
+ }
192
221
}
193
222
194
223
public struct UserIdentity : Codable , Hashable , Identifiable , Sendable {
0 commit comments