Skip to content

Commit b10d454

Browse files
author
Chuan Ren
authored
Add support of web.app as an auth domain (#2959)
1 parent 9228743 commit b10d454

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

Firebase/Auth/Source/AuthProvider/Phone/FIRPhoneAuthProvider.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ typedef void (^FIRVerifyClientCallback)(FIRAuthAppCredential *_Nullable appCrede
6666
*/
6767
typedef void (^FIRFetchAuthDomainCallback)(NSString *_Nullable authDomain,
6868
NSError *_Nullable error);
69-
/** @var kAuthDomainSuffix
70-
@brief The suffix of the auth domain pertiaining to a given Firebase project.
71-
*/
72-
static NSString *const kAuthDomainSuffix = @"firebaseapp.com";
7369

7470
/** @var kauthTypeVerifyApp
7571
@brief The auth type to be specified in the app verification request.

Firebase/Auth/Source/Utilities/FIRAuthWebUtils.m

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323

2424
NS_ASSUME_NONNULL_BEGIN
2525

26-
/** @var kAuthDomainSuffix
27-
@brief The suffix of the auth domain pertiaining to a given Firebase project.
28-
*/
29-
static NSString *const kAuthDomainSuffix = @"firebaseapp.com";
30-
3126
@implementation FIRAuthWebUtils
3227

28+
+ (NSArray<NSString *> *)supportedAuthDomains {
29+
return @[@"firebaseapp.com", @"web.app"];
30+
}
31+
3332
+ (NSString *)randomStringWithLength:(NSUInteger)length {
3433
NSMutableString *randomString = [[NSMutableString alloc] init];
3534
for (int i=0; i < length; i++) {
@@ -99,11 +98,13 @@ + (void)fetchAuthDomainWithRequestConfiguration:(FIRAuthRequestConfiguration *)r
9998
}
10099
NSString *authDomain;
101100
for (NSString *domain in response.authorizedDomains) {
102-
NSInteger index = domain.length - kAuthDomainSuffix.length;
103-
if (index >= 2) {
104-
if ([domain hasSuffix:kAuthDomainSuffix] && domain.length >= kAuthDomainSuffix.length + 2) {
105-
authDomain = domain;
106-
break;
101+
for (NSString *suportedAuthDomain in [self supportedAuthDomains]) {
102+
NSInteger index = domain.length - suportedAuthDomain.length;
103+
if (index >= 2) {
104+
if ([domain hasSuffix:suportedAuthDomain] && domain.length >= suportedAuthDomain.length + 2) {
105+
authDomain = domain;
106+
break;
107+
}
107108
}
108109
}
109110
}

0 commit comments

Comments
 (0)