Skip to content

Commit

Permalink
fix(auth): add missing nonce param when updating user
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Jul 11, 2024
1 parent 3e45b5a commit 1b8589b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
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"

0 comments on commit 1b8589b

Please sign in to comment.