Skip to content

Commit 7d95eee

Browse files
prakhar1989bojeil-google
authored andcommitted
moved requireDisplayName config to signInOptions
1 parent 0249b57 commit 7d95eee

File tree

4 files changed

+46
-13
lines changed

4 files changed

+46
-13
lines changed

demo/public/app.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ var uiConfig = {
4444
},
4545
firebase.auth.TwitterAuthProvider.PROVIDER_ID,
4646
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+
}
4852
],
4953
// 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'
5355
};
5456

5557
// Initialize the FirebaseUI Widget using Firebase.

javascript/utils/idp.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ firebaseui.auth.idp.isSupportedProvider = function(providerId) {
2828
};
2929

3030

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+
3139
/**
3240
* Supported IdP auth provider.
3341
* @package {Object<string, firebase.auth.AuthProvider>}

javascript/widgets/config.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ firebaseui.auth.widget.Config = function() {
6868
this.config_.define('siteName');
6969
this.config_.define('tosUrl');
7070
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);
7671
};
7772

7873

@@ -295,9 +290,21 @@ firebaseui.auth.widget.Config.prototype.getTosUrl = function() {
295290
};
296291

297292

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+
*/
299297
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);
301308
};
302309

303310

javascript/widgets/config_test.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,25 @@ function testGetTosUrl() {
242242
}
243243

244244

245-
function testShouldDisplayName() {
245+
function testRequiredDisplayNameShouldBeTrueByDefault() {
246246
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+
]);
248264
assertFalse(config.getRequireDisplayName());
249265
}
250266

0 commit comments

Comments
 (0)