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

[Auth] Add custom provider support for AuthProviderID #13433

Merged
merged 2 commits into from
Jul 31, 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
5 changes: 5 additions & 0 deletions FirebaseAuth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 11.1.0
- [added] Added custom provider support to `AuthProviderID`. Note that this change will be breaking
to any code that implemented an exhaustive `switch` on `AuthProviderID` in 11.0.0 - the `switch`
will need expansion. (#13429)

# 11.0.0
- [fixed] Fixed auth domain matching code to prioritize matching `firebaseapp.com` over `web.app`
even if the server returns the `web.app` domain listed first. (#7992)
Expand Down
57 changes: 57 additions & 0 deletions FirebaseAuth/Sources/Swift/AuthProvider/AuthProviderID.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

/// Enumeration of the available Auth Provider IDs.
public struct AuthProviderID: Equatable {
public let rawValue: String
paulb777 marked this conversation as resolved.
Show resolved Hide resolved
private init(rawValue: String) {
self.rawValue = rawValue
}
}

public extension AuthProviderID {
static var apple: Self {
Self(rawValue: "apple.com")
}

static var email: Self {
Self(rawValue: "password")
}

static var facebook: Self {
Self(rawValue: "facebook.com")
}

static var gameCenter: Self {
Self(rawValue: "gc.apple.com")
}

static var gitHub: Self {
Self(rawValue: "github.com")
}

static var google: Self {
Self(rawValue: "google.com")
}

static var phone: Self {
Self(rawValue: "phone")
}

static func custom(_ value: String) -> Self {
Self(rawValue: value)
}
}
26 changes: 0 additions & 26 deletions FirebaseAuth/Sources/Swift/AuthProvider/AuthProviderStrings.swift

This file was deleted.

23 changes: 23 additions & 0 deletions FirebaseAuth/Tests/Unit/SwiftAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -702,4 +702,27 @@ class AuthAPI_hOnlyTests: XCTestCase {
if let _: Date = metadata.lastSignInDate,
let _: Date = metadata.creationDate {}
}

func regression13429(id: AuthProviderID) -> Int {
switch id {
ncooke3 marked this conversation as resolved.
Show resolved Hide resolved
case .apple:
return 1
case .email:
return 2
case .facebook:
return 3
case .gameCenter:
return 4
case .gitHub:
return 5
case .google:
return 6
case .phone:
return 7
case .custom("myCustom"):
return 8
default:
return 9
}
}
}
Loading