Skip to content

Commit e3ddf43

Browse files
committed
decode GenerateLinkResponse
1 parent eedd2ba commit e3ddf43

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

Sources/Auth/Types.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -994,10 +994,8 @@ public struct GenerateLinkResponse: Hashable, Sendable, Decodable {
994994
public let user: User
995995

996996
public init(from decoder: any Decoder) throws {
997-
let container = try decoder.singleValueContainer()
998-
999-
self.user = try container.decode(User.self)
1000-
self.properties = try container.decode(GenerateLinkProperties.self)
997+
self.properties = try GenerateLinkProperties(from: decoder)
998+
self.user = try User(from: decoder)
1001999
}
10021000
}
10031001

Tests/AuthTests/AuthClientTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,7 @@ final class AuthClientTests: XCTestCase {
20802080

20812081
expectNoDifference(
20822082
link.properties.actionLink.absoluteString,
2083-
"https://example.com/auth/v1/verify?type=signup&token={hashed_token}&redirect_to=https://example.com"
2083+
"https://example.com/auth/v1/verify?type=signup&token={hashed_token}&redirect_to=https://example.com".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
20842084
)
20852085
}
20862086

Tests/IntegrationTests/AuthClientIntegrationTests.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class AuthClientIntegrationTests: XCTestCase {
3030
"Authorization": "Bearer \(key)",
3131
],
3232
localStorage: InMemoryLocalStorage(),
33-
logger: nil
33+
logger: TestLogger()
3434
)
3535
)
3636
}
@@ -173,7 +173,9 @@ final class AuthClientIntegrationTests: XCTestCase {
173173
let session = try await signUpIfNeededOrSignIn(email: mockEmail(), password: mockPassword())
174174
let identities = try await authClient.userIdentities()
175175
expectNoDifference(
176-
session.user.identities?.map(\.identityId) ?? [], identities.map(\.identityId))
176+
session.user.identities?.map(\.identityId) ?? [],
177+
identities.map(\.identityId)
178+
)
177179
}
178180

179181
func testUnlinkIdentity_withOnlyOneIdentity() async throws {
@@ -295,7 +297,14 @@ final class AuthClientIntegrationTests: XCTestCase {
295297
func testGenerateLink_magicLink() async throws {
296298
let client = Self.makeClient(serviceRole: true)
297299
let email = mockEmail()
300+
let password = mockPassword()
301+
302+
// first create a user
303+
try await client.admin.createUser(
304+
attributes: AdminUserAttributes(email: email, password: password)
305+
)
298306

307+
// generate a magic link for the created user
299308
let link = try await client.admin.generateLink(params: .magicLink(email: email))
300309

301310
expectNoDifference(link.properties.verificationType, .magiclink)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.22.6
1+
v2.22.12

0 commit comments

Comments
 (0)