Skip to content

Oob section #12421

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

Merged
merged 42 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2964dfe
Add PhoneAuth details in Settings view
pragatimodi Jan 29, 2024
c594c19
undo SwiftApplication.plist changes
pragatimodi Jan 29, 2024
354a6ef
undo SwiftApplication.plist changes
pragatimodi Jan 29, 2024
3ab2ac8
undo SwiftApplication.plist changes
pragatimodi Jan 29, 2024
ae27388
clang formatting
pragatimodi Jan 29, 2024
e057b17
game center auth login
pragatimodi Feb 6, 2024
b38a988
lint
pragatimodi Feb 6, 2024
c4d8943
correct method name
pragatimodi Feb 6, 2024
121c656
add game center icon
pragatimodi Feb 6, 2024
e6b298f
add game center account linking
pragatimodi Feb 6, 2024
46e2b62
Merge branch 'game-center' of https://github.com/firebase/firebase-io…
pragatimodi Feb 6, 2024
417168b
lint
pragatimodi Feb 6, 2024
660551c
add app-section
pragatimodi Feb 23, 2024
c704b1a
undo accidental changes
pragatimodi Feb 23, 2024
22272f2
lint fixes
pragatimodi Feb 23, 2024
dd5d5a9
add game center to AuthMenu
pragatimodi Feb 23, 2024
cd79c97
add verifyClient() method
pragatimodi Feb 24, 2024
7bf243d
fix .plist line deletion
pragatimodi Mar 12, 2024
9b5639c
fix unit test
pragatimodi Mar 12, 2024
4f8fbb4
Merge branch 'auth-swift' of https://github.com/firebase/firebase-ios…
pragatimodi Mar 18, 2024
0471e5d
Merge branch 'auth-swift' of https://github.com/firebase/firebase-ios…
pragatimodi Mar 18, 2024
72d213d
Merge branch 'settings-phoneauth' of https://github.com/firebase/fire…
pragatimodi Mar 18, 2024
50d308a
Merge branch 'auth-swift' of https://github.com/firebase/firebase-ios…
pragatimodi Apr 3, 2024
ffcee37
Merge branch 'game-center' of https://github.com/firebase/firebase-io…
pragatimodi Apr 3, 2024
db885d7
style.sh changes
pragatimodi Apr 3, 2024
19b6c57
remove authMenu test
pragatimodi Apr 4, 2024
b55b1f1
style
pragatimodi Apr 4, 2024
7235386
comment out AuthMenu UI test
pragatimodi Apr 4, 2024
1c331eb
cleanup
pragatimodi Apr 4, 2024
8171aca
Merge branch 'game-center' of https://github.com/firebase/firebase-io…
pragatimodi Apr 4, 2024
bd47b2a
oob section changes
pragatimodi Apr 9, 2024
23e7899
lint
pragatimodi Apr 9, 2024
22358a2
undo whitespace changes
pragatimodi Apr 9, 2024
fb323ae
fix bracket
pragatimodi Apr 10, 2024
f5d8b4f
lint
pragatimodi Apr 10, 2024
da89955
Merge branch 'auth-swift' of https://github.com/firebase/firebase-ios…
pragatimodi May 6, 2024
53f4dde
oob-section changes
pragatimodi May 6, 2024
e70c435
lint
pragatimodi May 6, 2024
ae791c9
lint
pragatimodi May 6, 2024
20c6668
apply suggestions from code review
pragatimodi May 6, 2024
63e01b9
debugged
pragatimodi May 6, 2024
fcd9055
lint
pragatimodi May 6, 2024
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "gamecontroller.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,35 @@ enum AuthMenu: String {
case gitHub = "github.com"
case yahoo = "yahoo.com"
case facebook = "facebook.com"
case gameCenter = "gc.apple.com"
case emailPassword = "password"
case passwordless = "emailLink"
case phoneNumber = "phone"
case anonymous
case custom
case initRecaptcha
case customAuthDomain
case getToken
case getTokenForceRefresh
case addAuthStateChangeListener
case removeLastAuthStateChangeListener
case addIdTokenChangeListener
case removeLastIdTokenChangeListener
case verifyClient
case deleteApp
case actionType
case continueURL
case requestVerifyEmail
case requestPasswordReset
case resetPassword
case checkActionCode
case applyActionCode
case verifyPasswordResetCode

/// More intuitively named getter for `rawValue`.
// More intuitively named getter for `rawValue`.
var id: String { rawValue }

/// The UI friendly name of the `AuthMenu`. Used for display.
// The UI friendly name of the `AuthMenu`. Used for display.
var name: String {
switch self {
case .settings:
Expand All @@ -54,6 +71,8 @@ enum AuthMenu: String {
return "Yahoo"
case .facebook:
return "Facebook"
case .gameCenter:
return "Game Center"
case .emailPassword:
return "Email & Password Login"
case .passwordless:
Expand All @@ -68,11 +87,44 @@ enum AuthMenu: String {
return "Initialize reCAPTCHA Enterprise"
case .customAuthDomain:
return "Set Custom Auth Domain"
case .getToken:
return "Get Token"
case .getTokenForceRefresh:
return "Get Token Force Refresh"
case .addAuthStateChangeListener:
return "Add Auth State Change Listener"
case .removeLastAuthStateChangeListener:
return "Remove Last Auth State Change Listener"
case .addIdTokenChangeListener:
return "Add ID Token Change Listener"
case .removeLastIdTokenChangeListener:
return "Remove Last ID Token Change Listener"
case .verifyClient:
return "Verify Client"
case .deleteApp:
return "Delete App"
// OOB
case .actionType:
return "Action Type"
case .continueURL:
return "Continue URL"
case .requestVerifyEmail:
return "Request Verify Email"
case .requestPasswordReset:
return "Request Password Reset"
case .resetPassword:
return "Reset Password"
case .checkActionCode:
return "Check Action Code"
case .applyActionCode:
return "Apply Action Code"
case .verifyPasswordResetCode:
return "Verify Password Reset Code"
}
}

/// Failable initializer to create an `AuthMenu` from it's corresponding `name` value.
/// - Parameter rawValue: String value representing `AuthMenu`'s name or type.
// Failable initializer to create an `AuthMenu` from its corresponding `name` value.
// - Parameter rawValue: String value representing `AuthMenu`'s name or type.
init?(rawValue: String) {
switch rawValue {
case "Settings":
Expand All @@ -91,6 +143,8 @@ enum AuthMenu: String {
self = .yahoo
case "Facebook":
self = .facebook
case "Game Center":
self = .gameCenter
case "Email & Password Login":
self = .emailPassword
case "Email Link/Passwordless":
Expand All @@ -105,21 +159,84 @@ enum AuthMenu: String {
self = .initRecaptcha
case "Set Custom Auth Domain":
self = .customAuthDomain
default: return nil
case "Get Token":
self = .getToken
case "Get Token Force Refresh":
self = .getTokenForceRefresh
case "Add Auth State Change Listener":
self = .addAuthStateChangeListener
case "Remove Last Auth State Change Listener":
self = .removeLastAuthStateChangeListener
case "Add ID Token Change Listener":
self = .addIdTokenChangeListener
case "Remove Last ID Token Change Listener":
self = .removeLastIdTokenChangeListener
case "Verify Client":
self = .verifyClient
case "Delete App":
self = .deleteApp
case "Action Type":
self = .actionType
case "Continue URL":
self = .continueURL
case "Request Verify Email":
self = .requestVerifyEmail
case "Request Password Reset":
self = .requestPasswordReset
case "Reset Password":
self = .resetPassword
case "Check Action Code":
self = .checkActionCode
case "Apply Action Code":
self = .applyActionCode
case "Verify Password Reset Code":
self = .verifyPasswordResetCode
default:
return nil
}
}
}

enum ActionCodeRequestType: String {
case email
case `continue`
case inApp

var name: String {
switch self {
case .email:
return "Email Only"
case .inApp:
return "In-App + Continue URL"
case .continue:
return "Continue URL"
}
}

init?(rawValue: String) {
switch rawValue {
case "Email Only":
self = .email
case "In-App + Continue URL":
self = .inApp
case "Continue URL":
self = .continue
default:
return nil
}
}
}

// MARK: DataSourceProvidable

extension AuthMenu: DataSourceProvidable {
class AuthMenuData: DataSourceProvidable {
private static var providers: [AuthMenu] {
[.google, .apple, .twitter, .microsoft, .gitHub, .yahoo, .facebook]
[.google, .apple, .twitter, .microsoft, .gitHub, .yahoo, .facebook, .gameCenter]
}

static var settingsSection: Section {
let header = "Auth Settings"
let item = Item(title: settings.name, hasNestedContent: true)
let item = Item(title: AuthMenu.settings.name, hasNestedContent: true)
return Section(headerDescription: header, items: [item])
}

Expand All @@ -133,7 +250,7 @@ extension AuthMenu: DataSourceProvidable {
static var emailPasswordSection: Section {
let image = UIImage(named: "firebaseIcon")
let header = "Email and Password Login"
let item = Item(title: emailPassword.name, hasNestedContent: true, image: image)
let item = Item(title: AuthMenu.emailPassword.name, hasNestedContent: true, image: image)
return Section(headerDescription: header, items: [item])
}

Expand All @@ -144,10 +261,10 @@ extension AuthMenu: DataSourceProvidable {
let shieldSymbol = UIImage.systemImage("lock.shield.fill", tintColor: .systemOrange)

let otherOptions = [
Item(title: passwordless.name, image: lockSymbol),
Item(title: phoneNumber.name, image: phoneSymbol),
Item(title: anonymous.name, image: anonSymbol),
Item(title: custom.name, image: shieldSymbol),
Item(title: AuthMenu.passwordless.name, image: lockSymbol),
Item(title: AuthMenu.phoneNumber.name, image: phoneSymbol),
Item(title: AuthMenu.anonymous.name, image: anonSymbol),
Item(title: AuthMenu.custom.name, image: shieldSymbol),
]
let header = "Other Authentication Methods"
return Section(headerDescription: header, items: otherOptions)
Expand All @@ -156,29 +273,58 @@ extension AuthMenu: DataSourceProvidable {
static var recaptchaSection: Section {
let image = UIImage(named: "firebaseIcon")
let header = "Initialize reCAPTCHA Enterprise"
let item = Item(title: initRecaptcha.name, hasNestedContent: false, image: image)
let item = Item(title: AuthMenu.initRecaptcha.name, hasNestedContent: false, image: image)
return Section(headerDescription: header, items: [item])
}

static var customAuthDomainSection: Section {
let image = UIImage(named: "firebaseIcon")
let header = "Custom Auth Domain"
let item = Item(title: customAuthDomain.name, hasNestedContent: false, image: image)
let item = Item(title: AuthMenu.customAuthDomain.name, hasNestedContent: false, image: image)
return Section(headerDescription: header, items: [item])
}

static var sections: [Section] {
[settingsSection, providerSection, emailPasswordSection, otherSection, recaptchaSection,
customAuthDomainSection]
static var appSection: Section {
let header = "APP"
let items: [Item] = [
Item(title: AuthMenu.getToken.name),
Item(title: AuthMenu.getTokenForceRefresh.name),
Item(title: AuthMenu.addAuthStateChangeListener.name),
Item(title: AuthMenu.removeLastAuthStateChangeListener.name),
Item(title: AuthMenu.addIdTokenChangeListener.name),
Item(title: AuthMenu.removeLastIdTokenChangeListener.name),
Item(title: AuthMenu.verifyClient.name),
Item(title: AuthMenu.deleteApp.name),
]
return Section(headerDescription: header, items: items)
}

static var oobSection: Section {
let header = "OOB"
let items: [Item] = [
Item(title: AuthMenu.actionType.name, detailTitle: ActionCodeRequestType.inApp.name),
Item(title: AuthMenu.continueURL.name, detailTitle: "--", isEditable: true),
Item(title: AuthMenu.requestVerifyEmail.name),
Item(title: AuthMenu.requestPasswordReset.name),
Item(title: AuthMenu.resetPassword.name),
Item(title: AuthMenu.checkActionCode.name),
Item(title: AuthMenu.applyActionCode.name),
Item(title: AuthMenu.verifyPasswordResetCode.name),
]
return Section(headerDescription: header, items: items)
}

static var sections: [Section] =
[settingsSection, providerSection, emailPasswordSection, otherSection, recaptchaSection,
customAuthDomainSection, appSection, oobSection]

static var authLinkSections: [Section] {
let allItems = AuthMenu.sections.flatMap { $0.items }
let allItems = AuthMenuData.sections.flatMap { $0.items }
let header = "Manage linking between providers"
let footer =
"Select an unchecked row to link the currently signed in user to that auth provider. To unlink the user from a linked provider, select its corresponding row marked with a checkmark."
return [Section(headerDescription: header, footerDescription: footer, items: allItems)]
}

var sections: [Section] { AuthMenu.sections }
var sections: [Section] = AuthMenuData.sections
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class DataSourceProvider<DataSource: DataSourceProvidable>: NSObject, UITableVie
return sectionItem(at: indexPath)
}

public func updateItem(at indexPath: IndexPath, item: Item) -> DataSource.Section.Item {
return editSectionItem(at: indexPath, item: item)
}

// MARK: - UITableViewDataSource

func numberOfSections(in tableView: UITableView) -> Int {
Expand Down Expand Up @@ -101,6 +105,11 @@ class DataSourceProvider<DataSource: DataSourceProvidable>: NSObject, UITableVie
return sections[indexPath.section].items[indexPath.row]
}

private func editSectionItem(at indexPath: IndexPath, item: Item) -> DataSource.Section.Item {
sections[indexPath.section].items[indexPath.row] = item as! DataSource.Section.Item
return sectionItem(at: indexPath)
}

private func config(_ label: inout UILabel, for section: DataSource.Section) {
label.text = section.headerDescription
label.textColor = .label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ extension User: DataSourceProvidable {
// MARK: - UIKit Extensions

public extension UIViewController {
func displayInfo(title: String, message: String, style: UIAlertController.Style) {
let alert = UIAlertController(title: title, message: message, preferredStyle: style)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))

DispatchQueue.main.async { // Ensure UI updates on the main thread
self.present(alert, animated: true, completion: nil)
}
}

func displayError(_ error: Error?, from function: StaticString = #function) {
guard let error = error else { return }
print("ⓧ Error in \(function): \(error.localizedDescription)")
Expand Down
Loading