@@ -116,11 +116,10 @@ abstract class AuthProvider(open val providerId: String) {
116116 ) : AuthProvider(providerId = Provider .EMAIL .id) {
117117 fun validate () {
118118 if (isEmailLinkSignInEnabled) {
119- val actionCodeSettings = actionCodeSettings
120- ? : requireNotNull(actionCodeSettings) {
121- " ActionCodeSettings cannot be null when using " +
122- " email link sign in."
123- }
119+ val actionCodeSettings = requireNotNull(actionCodeSettings) {
120+ " ActionCodeSettings cannot be null when using " +
121+ " email link sign in."
122+ }
124123
125124 check(actionCodeSettings.canHandleCodeInApp()) {
126125 " You must set canHandleCodeInApp in your " +
@@ -176,8 +175,10 @@ abstract class AuthProvider(open val providerId: String) {
176175 }
177176 }
178177
179- check(PhoneNumberUtils .isValidIso(defaultCountryCode)) {
180- " Invalid country iso: $defaultCountryCode "
178+ defaultCountryCode?.let {
179+ check(PhoneNumberUtils .isValidIso(it)) {
180+ " Invalid country iso: $it "
181+ }
181182 }
182183
183184 allowedCountries?.forEach { code ->
@@ -233,23 +234,25 @@ abstract class AuthProvider(open val providerId: String) {
233234 fun validate (context : Context ) {
234235 // TODO(demolaf): do we need this? since we are requesting this in AuthProvider.Google?
235236 // if serverClientId is nullable do we still need to throw an IllegalStateException?
236- Preconditions .checkConfigured(
237- context,
238- " Check your google-services plugin configuration, the" +
239- " default_web_client_id string wasn't populated." ,
240- R .string.default_web_client_id
241- )
242-
243- for (scope in scopes) {
244- if (" email" == scope) {
245- Log .w(
246- " AuthProvider.Google" ,
247- " The GoogleSignInOptions passed to setSignInOptions does not " +
248- " request the 'email' scope. In most cases this is a mistake! " +
249- " Call requestEmail() on the GoogleSignInOptions object."
250- )
251- break
252- }
237+ // if (serverClientId == null) {
238+ // Preconditions.checkConfigured(
239+ // context,
240+ // "Check your google-services plugin configuration, the" +
241+ // " default_web_client_id string wasn't populated.",
242+ // R.string.default_web_client_id
243+ // )
244+ // } else {
245+ // require(serverClientId.isNotBlank()) {
246+ // "Server client ID cannot be blank."
247+ // }
248+ // }
249+
250+ val hasEmailScope = scopes.contains(" email" )
251+ if (! hasEmailScope) {
252+ Log .w(
253+ " AuthProvider.Google" ,
254+ " The scopes do not include 'email'. In most cases this is a mistake!"
255+ )
253256 }
254257 }
255258 }
@@ -258,6 +261,11 @@ abstract class AuthProvider(open val providerId: String) {
258261 * Facebook Login provider configuration.
259262 */
260263 class Facebook (
264+ /* *
265+ * The Facebook application ID.
266+ */
267+ val applicationId : String? = null ,
268+
261269 /* *
262270 * The list of scopes (permissions) to request. Defaults to email and public_profile.
263271 */
@@ -278,22 +286,27 @@ abstract class AuthProvider(open val providerId: String) {
278286 customParameters = customParameters
279287 ) {
280288 fun validate (context : Context ) {
281- if (ProviderAvailability .IS_FACEBOOK_AVAILABLE ) {
289+ if (! ProviderAvailability .IS_FACEBOOK_AVAILABLE ) {
282290 throw RuntimeException (
283291 " Facebook provider cannot be configured " +
284292 " without dependency. Did you forget to add " +
285293 " 'com.facebook.android:facebook-login:VERSION' dependency?"
286294 )
287295 }
288296
289- // TODO(demolaf): is this required? or should we add appId to AuthProvider.Facebook
290- // parameters above?
291- Preconditions .checkConfigured(
292- context,
293- " Facebook provider unconfigured. Make sure to " +
294- " add a `facebook_application_id` string." ,
295- R .string.facebook_application_id
296- )
297+ // Check application ID - either from parameter or string resources
298+ // if (applicationId == null) {
299+ // Preconditions.checkConfigured(
300+ // context,
301+ // "Facebook provider unconfigured. Make sure to " +
302+ // "add a `facebook_application_id` string or provide applicationId parameter.",
303+ // R.string.facebook_application_id
304+ // )
305+ // } else {
306+ // require(applicationId.isNotBlank()) {
307+ // "Facebook application ID cannot be blank"
308+ // }
309+ // }
297310 }
298311 }
299312
@@ -447,5 +460,15 @@ abstract class AuthProvider(open val providerId: String) {
447460 providerId = providerId,
448461 scopes = scopes,
449462 customParameters = customParameters
450- )
463+ ) {
464+ fun validate () {
465+ require(providerId.isNotBlank()) {
466+ " Provider ID cannot be null or empty"
467+ }
468+
469+ require(buttonLabel.isNotBlank()) {
470+ " Button label cannot be null or empty"
471+ }
472+ }
473+ }
451474}
0 commit comments