Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auth): add missing nonce param when updating user #457

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Sources/Auth/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,12 @@ public struct UserAttributes: Codable, Hashable, Sendable {
public var phone: String?
/// The user's password.
public var password: String?

/// The nonce sent for reauthentication if the user's password is to be updated.
///
/// Note: Call ``AuthClient/reauthenticate()`` to obtain the nonce first.
public var nonce: String?

/// An email change token.
public var emailChangeToken: String?
/// A custom data object to store the user's metadata. This maps to the `auth.users.user_metadata`
Expand All @@ -479,12 +485,14 @@ public struct UserAttributes: Codable, Hashable, Sendable {
email: String? = nil,
phone: String? = nil,
password: String? = nil,
nonce: String? = nil,
emailChangeToken: String? = nil,
data: [String: AnyJSON]? = nil
) {
self.email = email
self.phone = phone
self.password = password
self.nonce = nonce
self.emailChangeToken = emailChangeToken
self.data = data
}
Expand Down
1 change: 1 addition & 0 deletions Tests/AuthTests/RequestsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ final class RequestsTests: XCTestCase {
email: "[email protected]",
phone: "+1 202-918-2132",
password: "another.pass",
nonce: "abcdef",
emailChangeToken: "123456",
data: ["custom_key": .string("custom_value")]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ curl \
--header "Authorization: Bearer accesstoken" \
--header "Content-Type: application/json" \
--header "X-Client-Info: gotrue-swift/x.y.z" \
--data "{\"data\":{\"custom_key\":\"custom_value\"},\"email\":\"[email protected]\",\"email_change_token\":\"123456\",\"password\":\"another.pass\",\"phone\":\"+1 202-918-2132\"}" \
--data "{\"data\":{\"custom_key\":\"custom_value\"},\"email\":\"[email protected]\",\"email_change_token\":\"123456\",\"nonce\":\"abcdef\",\"password\":\"another.pass\",\"phone\":\"+1 202-918-2132\"}" \
"http://localhost:54321/auth/v1/user"
Loading