Skip to content

Commit f1db4bf

Browse files
prakhar1989bojeil-google
authored andcommitted
incorporated PR comments
1 parent 7d95eee commit f1db4bf

File tree

6 files changed

+36
-13
lines changed

6 files changed

+36
-13
lines changed

javascript/ui/page/passwordsignup_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function testDisplayNameIsNotRendered() {
126126
firebaseui.auth.ui.element.FormTestHelper.prototype.onSubmit,
127127
formTestHelper));
128128
component.render(root);
129-
assertEquals(component.getNameElement(), null);
129+
assertNull(component.getNameElement());
130130
}
131131

132132

javascript/widgets/config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,14 @@ firebaseui.auth.widget.Config.prototype.getTosUrl = function() {
296296
*/
297297
firebaseui.auth.widget.Config.prototype.getRequireDisplayName = function() {
298298
var signInOptions = this.getSignInOptions_();
299-
var requireDisplayName = true;
300299

301300
for (var i = 0; i < signInOptions.length; i++) {
302301
if (signInOptions[i]['provider'] === firebaseui.auth.idp.EMAIL_PROVIDER_ID
303302
&& signInOptions[i]['requireDisplayName'] !== undefined) {
304-
requireDisplayName = signInOptions[i]['requireDisplayName'];
303+
return /** @type {boolean} */ (signInOptions[i]['requireDisplayName']);
305304
}
306305
}
307-
return /** @type {boolean} */ (requireDisplayName);
306+
return true;
308307
};
309308

310309

javascript/widgets/config_test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ function testRequiredDisplayNameShouldBeTrueByDefault() {
246246
assertTrue(config.getRequireDisplayName());
247247
}
248248

249+
249250
function testRequiredDisplayNameCanBeSet() {
250251
config.update('signInOptions', [
251252
{

javascript/widgets/handler/passwordsignup.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,19 @@ firebaseui.auth.widget.handler.onSignUpSubmit_ = function(app, component) {
105105
),
106106
[email, password],
107107
function(user) {
108-
// Sign up successful. We can now set the name.
109-
return app.registerPending(user.updateProfile({'displayName': name})
110-
.then(function() {
111-
// Pass password credential to complete the sign-in to original
112-
// auth instance.
113-
firebaseui.auth.widget.handler.common.setLoggedIn(
114-
app, component, emailPassCred);
115-
}));
108+
if (requireDisplayName) {
109+
// Sign up successful. We can now set the name.
110+
return app.registerPending(user.updateProfile({'displayName': name})
111+
.then(function() {
112+
// Pass password credential to complete the sign-in to original
113+
// auth instance.
114+
firebaseui.auth.widget.handler.common.setLoggedIn(
115+
app, component, emailPassCred);
116+
}));
117+
} else {
118+
return firebaseui.auth.widget.handler.common.setLoggedIn(
119+
app, component, emailPassCred);
120+
}
116121
},
117122
function(error) {
118123
// Ignore error if cancelled by the client.

soy/pages_test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ function testPasswordSignUp() {
103103
firebaseui.auth.soy2.page.passwordSignUp,
104104
{
105105
'email': '[email protected]',
106+
'requireDisplayName': true,
107+
'allowCancel': true
108+
},
109+
IJ_DATA_);
110+
}
111+
112+
113+
function testPasswordSignUpWithoutDisplayName() {
114+
var root = goog.dom.getElement('password-sign-up-no-name');
115+
goog.soy.renderElement(
116+
root,
117+
firebaseui.auth.soy2.page.passwordSignUp,
118+
{
119+
'email': '[email protected]',
120+
'requireDisplayName': false,
106121
'allowCancel': true
107122
},
108123
IJ_DATA_);

soy/pages_test_dom.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@
4141

4242
<!-- passwordSignUp -->
4343
<tr>
44-
<td rowspan="2">passwordSignUp</td>
44+
<td rowspan="3">passwordSignUp</td>
4545
<td><div id="password-sign-up"></div></td>
4646
</tr>
47+
<tr>
48+
<td><div id="password-sign-up-no-name"></div></td>
49+
</tr>
4750
<tr>
4851
<td><div id="password-sign-up-tos"></div></td>
4952
</tr>

0 commit comments

Comments
 (0)