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 channel param to signUp method #625

Merged
merged 1 commit into from
Dec 16, 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
3 changes: 3 additions & 0 deletions Sources/Auth/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,14 @@ public final class AuthClient: Sendable {
/// - Parameters:
/// - phone: User's phone number with international prefix.
/// - password: Password for the user.
/// - channel: Messaging channel to use (e.g. whatsapp or sms).
/// - data: Custom data object to store additional user metadata.
/// - captchaToken: Optional captcha token for securing this endpoint.
@discardableResult
public func signUp(
phone: String,
password: String,
channel: MessagingChannel = .sms,
data: [String: AnyJSON]? = nil,
captchaToken: String? = nil
) async throws -> AuthResponse {
Expand All @@ -260,6 +262,7 @@ public final class AuthClient: Sendable {
SignUpRequest(
password: password,
phone: phone,
channel: channel,
data: data,
gotrueMetaSecurity: captchaToken.map(AuthMetaSecurity.init(captchaToken:))
)
Expand Down
1 change: 1 addition & 0 deletions Sources/Auth/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct SignUpRequest: Codable, Hashable, Sendable {
var email: String?
var password: String?
var phone: String?
var channel: MessagingChannel?
var data: [String: AnyJSON]?
var gotrueMetaSecurity: AuthMetaSecurity?
var codeChallenge: String?
Expand Down
15 changes: 9 additions & 6 deletions Tests/AuthTests/RequestsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
// Created by Guilherme Souza on 07/10/23.
//

@testable import Auth
import Helpers
import InlineSnapshotTesting
import SnapshotTesting
import TestHelpers
import XCTest

@testable import Auth

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
Expand Down Expand Up @@ -126,7 +127,7 @@ final class RequestsTests: XCTestCase {
url,
URL(
string:
"http://localhost:54321/auth/v1/authorize?provider=github&scopes=read,write&redirect_to=https://dummy-url.com/redirect&extra_key=extra_value"
"http://localhost:54321/auth/v1/authorize?provider=github&scopes=read,write&redirect_to=https://dummy-url.com/redirect&extra_key=extra_value"
)!
)
}
Expand All @@ -152,7 +153,7 @@ final class RequestsTests: XCTestCase {

let url = URL(
string:
"https://dummy-url.com/callback#access_token=accesstoken&expires_in=60&refresh_token=refreshtoken&token_type=bearer"
"https://dummy-url.com/callback#access_token=accesstoken&expires_in=60&refresh_token=refreshtoken&token_type=bearer"
)!

let session = try await sut.session(from: url)
Expand All @@ -173,7 +174,7 @@ final class RequestsTests: XCTestCase {

let url = URL(
string:
"https://dummy-url.com/callback#access_token=accesstoken&expires_in=60&refresh_token=refreshtoken"
"https://dummy-url.com/callback#access_token=accesstoken&expires_in=60&refresh_token=refreshtoken"
)!

do {
Expand Down Expand Up @@ -430,7 +431,8 @@ final class RequestsTests: XCTestCase {
Dependencies[sut.clientID].sessionStorage.store(.validSession)

await assert {
_ = try await sut.mfa.enroll(params: MFAEnrollParams(issuer: "supabase.com", friendlyName: "test"))
_ = try await sut.mfa.enroll(
params: MFAEnrollParams(issuer: "supabase.com", friendlyName: "test"))
}
}

Expand Down Expand Up @@ -480,7 +482,8 @@ final class RequestsTests: XCTestCase {
Dependencies[sut.clientID].sessionStorage.store(.validSession)

await assert {
_ = try await sut.mfa.verify(params: .init(factorId: "123", challengeId: "123", code: "123456"))
_ = try await sut.mfa.verify(
params: .init(factorId: "123", challengeId: "123", code: "123456"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ curl \
--header "Content-Type: application/json" \
--header "X-Client-Info: gotrue-swift/x.y.z" \
--header "X-Supabase-Api-Version: 2024-01-01" \
--data "{\"data\":{\"custom_key\":\"custom_value\"},\"gotrue_meta_security\":{\"captcha_token\":\"dummy-captcha\"},\"password\":\"the.pass\",\"phone\":\"+1 202-918-2132\"}" \
--data "{\"channel\":\"sms\",\"data\":{\"custom_key\":\"custom_value\"},\"gotrue_meta_security\":{\"captcha_token\":\"dummy-captcha\"},\"password\":\"the.pass\",\"phone\":\"+1 202-918-2132\"}" \
"http://localhost:54321/auth/v1/signup"
Loading