Skip to content

Implemented Auth::UseUserAccessGroup for iOS and stubbed for other pl… #1753

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

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions auth/src/android/auth_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -676,5 +676,9 @@ void DisableTokenAutoRefresh(AuthData* auth_data) {}
void InitializeTokenRefresher(AuthData* auth_data) {}
void DestroyTokenRefresher(AuthData* auth_data) {}

AuthError Auth::UseUserAccessGroup(const char* access_group) {
return kAuthErrorUnimplemented;
}

} // namespace auth
} // namespace firebase
9 changes: 9 additions & 0 deletions auth/src/auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,5 +373,14 @@ AUTH_RESULT_FN(Auth, SignInWithEmailAndPassword, AuthResult)

AUTH_RESULT_FN(Auth, CreateUserWithEmailAndPassword, AuthResult)

AuthError Auth::UseUserAccessGroup(const char* access_group) {
if (!auth_data_) return kAuthErrorUninitialized;
#if FIREBASE_PLATFORM_IOS
return UseUserAccessGroupInternal(auth_data_, access_group);
#else
return kAuthErrorUnimplemented;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just return kAuthErrorNone.

#endif // FIREBASE_PLATFORM_IOS
}

} // namespace auth
} // namespace firebase
4 changes: 4 additions & 0 deletions auth/src/desktop/auth_desktop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@ void DestroyUserDataPersist(AuthData* auth_data) {
auth_data->auth->RemoveAuthStateListener(auth_impl->user_data_persist.get());
}

AuthError Auth::UseUserAccessGroup(const char* access_group) {
return kAuthErrorUnimplemented;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kAuthErrorNone

}

void LoadFinishTriggerListeners(AuthData* auth_data) {
MutexLock destructing_lock(auth_data->destructing_mutex);
if (auth_data->destructing) {
Expand Down
11 changes: 11 additions & 0 deletions auth/src/include/firebase/auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,17 @@ class Auth {
/// emulator.
///
void UseEmulator(std::string host, uint32_t port);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this out of the ifndef SWIG section

/// @brief Sets the user access group to use for data sharing.
///
/// This method is only functional on iOS. On other platforms, it will
/// immediately return kAuthErrorUnimplemented.
///
/// @param[in] access_group The access group to use.
///
/// @return kAuthErrorNone on success, or an AuthError code if an error
/// occurred.
AuthError UseUserAccessGroup(const char* access_group);
#endif //! defined(DOXYGEN), to hide the api from public documentation.

/// Gets the App this auth object is connected to.
Expand Down
10 changes: 10 additions & 0 deletions auth/src/ios/auth_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -608,5 +608,15 @@ void DisableTokenAutoRefresh(AuthData *auth_data) {}
void InitializeTokenRefresher(AuthData *auth_data) {}
void DestroyTokenRefresher(AuthData *auth_data) {}

AuthError UseUserAccessGroupInternal(AuthData* auth_data, const char* access_group) {
NSString* access_group_ns_string = access_group ? @(access_group) : nil;
NSError* error = nil;
BOOL success = [AuthImpl(auth_data) useUserAccessGroup:access_group_ns_string error:&error];
if (!success) {
return AuthErrorFromNSError(error);
}
return kAuthErrorNone;
}

} // namespace auth
} // namespace firebase
3 changes: 3 additions & 0 deletions auth/src/ios/common_ios.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ void SignInCallback(FIRUser *_Nullable user, NSError *_Nullable error,
/// like user interaction errors, they are actually caused by bad provider ids.
NSError *RemapBadProviderIDErrors(NSError *_Nonnull error);

// iOS-specific implementation of Auth::UseUserAccessGroup.
AuthError UseUserAccessGroupInternal(AuthData* auth_data, const char* access_group);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is simple enough not to need an Internal-based implementation, let's just implement it in the regular UseUserAccessGroup function.


} // namespace auth
} // namespace firebase

Expand Down
Loading