-
Notifications
You must be signed in to change notification settings - Fork 487
feat: Implement Twitter provider #1276
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
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
92e1453
feat: Implement Twitter provider
russellwheatley 819e05b
fix: twitter provider update to be pass through `withTwitterSignIn()`
russellwheatley c233113
fix: import twitter to allow sign-in
russellwheatley ef5f786
refactor: provider logic so it can be passed into button
russellwheatley ad137a0
fix: display name if email is unavailable, twitter sometimes user use…
russellwheatley 4cb5f27
chore: use withTwitterSignIn() for test and content view
russellwheatley 76e8ceb
feat: pass provider to providerWithUI
russellwheatley 5283f65
fix: renamed arg to make it clear the distinction between provider & …
russellwheatley 4dbd565
fix: make provider arg optional
russellwheatley 1b6a295
feat: implement API for deleting Twitter user
russellwheatley 7a37a33
fix: put delete function on the provider
russellwheatley ac7f146
format
russellwheatley 94415ff
feat: Twitter sign-in button styling
russellwheatley cab823c
chore: change button name to "X"
russellwheatley 854a506
test: sign in buttons are visible on auth picker
russellwheatley d1602f8
fix: sometimes email isn't available so use `as:` instead
russellwheatley 4897996
fix: remove incorrect naming
russellwheatley 855e40b
test: pass emulator argument
russellwheatley 5259847
test: test setup should be from tests
russellwheatley a643720
test: refactor tests so setup occurs before running test runner
russellwheatley 9c2255e
test: create test app function
russellwheatley d3d1f7b
test: remove duplicate test functions
russellwheatley 0e0c4b7
ci: separate into 3 jobs so tests can easily be re-run
russellwheatley 4a3eb71
ci: bump unit test timeout
russellwheatley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
FirebaseSwiftUI/FirebaseTwitterSwiftUI/Sources/Resources/Media.xcassets/Contents.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } | ||
|
|
26 changes: 26 additions & 0 deletions
26
...rebaseTwitterSwiftUI/Sources/Resources/Media.xcassets/twitter_logo.imageset/Contents.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "ic_twitter-white.png", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| }, | ||
| "properties" : { | ||
| "preserves-vector-representation" : true, | ||
| "template-rendering-intent" : "template" | ||
| } | ||
| } | ||
|
|
Binary file added
BIN
+101 KB
...tUI/Sources/Resources/Media.xcassets/twitter_logo.imageset/ic_twitter-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions
46
FirebaseSwiftUI/FirebaseTwitterSwiftUI/Sources/Services/AccountService+Twitter.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // | ||
| // AccountService+Twitter.swift | ||
| // FirebaseUI | ||
| // | ||
| // Created by Russell Wheatley on 10/10/2025. | ||
| // | ||
|
|
||
| @preconcurrency import FirebaseAuth | ||
| import FirebaseAuthSwiftUI | ||
| import Observation | ||
|
|
||
| protocol TwitterOperationReauthentication { | ||
| var twitterProvider: TwitterProviderSwift { get } | ||
| } | ||
|
|
||
| extension TwitterOperationReauthentication { | ||
| @MainActor func reauthenticate() async throws -> AuthenticationToken { | ||
| guard let user = Auth.auth().currentUser else { | ||
| throw AuthServiceError.reauthenticationRequired("No user currently signed-in") | ||
| } | ||
|
|
||
| do { | ||
| let credential = try await twitterProvider.createAuthCredential() | ||
| try await user.reauthenticate(with: credential) | ||
|
|
||
| return .firebase("") | ||
| } catch { | ||
| throw AuthServiceError.signInFailed(underlying: error) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @MainActor | ||
| class TwitterDeleteUserOperation: AuthenticatedOperation, | ||
| @preconcurrency TwitterOperationReauthentication { | ||
| let twitterProvider: TwitterProviderSwift | ||
| init(twitterProvider: TwitterProviderSwift) { | ||
| self.twitterProvider = twitterProvider | ||
| } | ||
|
|
||
| func callAsFunction(on user: User) async throws { | ||
| try await callAsFunction(on: user) { | ||
demolaf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| try await user.delete() | ||
| } | ||
| } | ||
| } | ||
31 changes: 31 additions & 0 deletions
31
FirebaseSwiftUI/FirebaseTwitterSwiftUI/Sources/Services/AuthService+Twitter.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright 2025 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. | ||
|
|
||
| // | ||
| // AuthService+Twitter.swift | ||
| // FirebaseUI | ||
| // | ||
| // Created by Russell Wheatley on 01/05/2025. | ||
| // | ||
|
|
||
| import FirebaseAuthSwiftUI | ||
|
|
||
| public extension AuthService { | ||
| @discardableResult | ||
| func withTwitterSignIn(_ provider: TwitterProviderSwift? = nil) -> AuthService { | ||
| registerProvider(providerWithButton: TwitterProviderAuthUI(provider: provider ?? | ||
| TwitterProviderSwift())) | ||
| return self | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it for testing? Maybe we could define a variable for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test process is separate from the app used to test the UI so I don't think it's worth it.