File tree Expand file tree Collapse file tree 4 files changed +46
-13
lines changed Expand file tree Collapse file tree 4 files changed +46
-13
lines changed Original file line number Diff line number Diff line change @@ -44,12 +44,14 @@ var uiConfig = {
44
44
} ,
45
45
firebase . auth . TwitterAuthProvider . PROVIDER_ID ,
46
46
firebase . auth . GithubAuthProvider . PROVIDER_ID ,
47
- firebase . auth . EmailAuthProvider . PROVIDER_ID
47
+ {
48
+ provider : firebase . auth . EmailAuthProvider . PROVIDER_ID ,
49
+ // Whether the display name should be displayed in Sign Up page.
50
+ requireDisplayName : true
51
+ }
48
52
] ,
49
53
// Terms of service url.
50
- 'tosUrl' : 'https://www.google.com' ,
51
- // Whether the display name should be displayed in Sign Up page.
52
- 'requireDisplayName' : false
54
+ 'tosUrl' : 'https://www.google.com'
53
55
} ;
54
56
55
57
// Initialize the FirebaseUI Widget using Firebase.
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ firebaseui.auth.idp.isSupportedProvider = function(providerId) {
28
28
} ;
29
29
30
30
31
+ /**
32
+ * The provider ID constant for the email auth provider
33
+ *
34
+ * @const {string}
35
+ */
36
+ firebaseui . auth . idp . EMAIL_PROVIDER_ID = 'password' ;
37
+
38
+
31
39
/**
32
40
* Supported IdP auth provider.
33
41
* @package {Object<string, firebase.auth.AuthProvider>}
Original file line number Diff line number Diff line change @@ -68,11 +68,6 @@ firebaseui.auth.widget.Config = function() {
68
68
this . config_ . define ( 'siteName' ) ;
69
69
this . config_ . define ( 'tosUrl' ) ;
70
70
this . config_ . define ( 'widgetUrl' ) ;
71
- /**
72
- * Determines whether the user is asked for entering display name
73
- * while going through the email/password signup flow.
74
- */
75
- this . config_ . define ( 'requireDisplayName' , true ) ;
76
71
} ;
77
72
78
73
@@ -295,9 +290,21 @@ firebaseui.auth.widget.Config.prototype.getTosUrl = function() {
295
290
} ;
296
291
297
292
298
- /** @return {boolean } Whether the display name should be displayed. */
293
+ /**
294
+ * @return {boolean } Whether the display name should be displayed.
295
+ * Defaults to true.
296
+ */
299
297
firebaseui . auth . widget . Config . prototype . getRequireDisplayName = function ( ) {
300
- return /** @type {boolean } */ ( this . config_ . get ( 'requireDisplayName' ) ) ;
298
+ var signInOptions = this . getSignInOptions_ ( ) ;
299
+ var requireDisplayName = true ;
300
+
301
+ for ( var i = 0 ; i < signInOptions . length ; i ++ ) {
302
+ if ( signInOptions [ i ] [ 'provider' ] === firebaseui . auth . idp . EMAIL_PROVIDER_ID
303
+ && signInOptions [ i ] [ 'requireDisplayName' ] !== undefined ) {
304
+ requireDisplayName = signInOptions [ i ] [ 'requireDisplayName' ] ;
305
+ }
306
+ }
307
+ return /** @type {boolean } */ ( requireDisplayName ) ;
301
308
} ;
302
309
303
310
Original file line number Diff line number Diff line change @@ -242,9 +242,25 @@ function testGetTosUrl() {
242
242
}
243
243
244
244
245
- function testShouldDisplayName ( ) {
245
+ function testRequiredDisplayNameShouldBeTrueByDefault ( ) {
246
246
assertTrue ( config . getRequireDisplayName ( ) ) ;
247
- config . update ( 'requireDisplayName' , false ) ;
247
+ }
248
+
249
+ function testRequiredDisplayNameCanBeSet ( ) {
250
+ config . update ( 'signInOptions' , [
251
+ {
252
+ 'provider' : 'password' ,
253
+ 'requireDisplayName' : true
254
+ }
255
+ ] ) ;
256
+ assertTrue ( config . getRequireDisplayName ( ) ) ;
257
+
258
+ config . update ( 'signInOptions' , [
259
+ {
260
+ 'provider' : 'password' ,
261
+ 'requireDisplayName' : false
262
+ }
263
+ ] ) ;
248
264
assertFalse ( config . getRequireDisplayName ( ) ) ;
249
265
}
250
266
You can’t perform that action at this time.
0 commit comments