Skip to content

Commit 6102ec8

Browse files
prakhar1989bojeil-google
authored andcommitted
incorporated PR feedback
1 parent f1db4bf commit 6102ec8

File tree

7 files changed

+90
-23
lines changed

7 files changed

+90
-23
lines changed

javascript/ui/page/passwordsignup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ firebaseui.auth.ui.page.PasswordSignUp.prototype.setupFocus_ = function() {
116116
if (!firebaseui.auth.ui.element.getInputValue(this.getEmailElement())) {
117117
this.getEmailElement().focus();
118118
} else if (this.requireDisplayName_ &&
119-
!firebaseui.auth.ui.element.getInputValue(this.getNameElement())) {
119+
!firebaseui.auth.ui.element.getInputValue(this.getNameElement())) {
120120
this.getNameElement().focus();
121121
} else {
122122
this.getNewPasswordElement().focus();

javascript/ui/page/passwordsignup_test.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function testInitialFocus_email() {
104104
}
105105

106106

107-
function testInitialFocus_name() {
107+
function testInitialFocus_nameIsRequired() {
108108
if (goog.userAgent.IE && !goog.userAgent.isDocumentModeOrHigher(9)) {
109109
return;
110110
}
@@ -114,7 +114,7 @@ function testInitialFocus_name() {
114114
}
115115

116116

117-
function testDisplayNameIsNotRendered() {
117+
function testInitialFocus_nameIsNotRequired() {
118118
if (goog.userAgent.IE && !goog.userAgent.isDocumentModeOrHigher(9)) {
119119
return;
120120
}
@@ -142,7 +142,7 @@ function testInitialFocus_newPassword() {
142142
}
143143

144144

145-
function testFocusToNameOnEmailEnter() {
145+
function testFocusOnEmailEnter_nameIsRequired() {
146146
goog.testing.events.fireKeySequence(
147147
component.getEmailElement(), goog.events.KeyCodes.ENTER);
148148
assertEquals(
@@ -151,6 +151,29 @@ function testFocusToNameOnEmailEnter() {
151151
}
152152

153153

154+
function testFocusOnEmailEnter_nameIsNotRequired() {
155+
if (goog.userAgent.IE && !goog.userAgent.isDocumentModeOrHigher(9)) {
156+
return;
157+
}
158+
component.dispose();
159+
component = new firebaseui.auth.ui.page.PasswordSignUp(
160+
null,
161+
false,
162+
goog.bind(
163+
firebaseui.auth.ui.element.FormTestHelper.prototype.onSubmit,
164+
formTestHelper));
165+
component.render(root);
166+
167+
// When name is not present, the focus should move to
168+
// password field on pressing enter.
169+
goog.testing.events.fireKeySequence(
170+
component.getEmailElement(), goog.events.KeyCodes.ENTER);
171+
assertEquals(
172+
component.getNewPasswordElement(),
173+
goog.dom.getActiveElement(document));
174+
}
175+
176+
154177
function testFocusToNewPasswordOnNameEnter() {
155178
goog.testing.events.fireKeySequence(
156179
component.getNameElement(), goog.events.KeyCodes.ENTER);

javascript/utils/idp.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ 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-
3931
/**
4032
* Supported IdP auth provider.
4133
* @package {Object<string, firebase.auth.AuthProvider>}

javascript/widgets/config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,14 @@ firebaseui.auth.widget.Config.prototype.getTosUrl = function() {
294294
* @return {boolean} Whether the display name should be displayed.
295295
* Defaults to true.
296296
*/
297-
firebaseui.auth.widget.Config.prototype.getRequireDisplayName = function() {
297+
firebaseui.auth.widget.Config.prototype.isDisplayNameRequired = function() {
298298
var signInOptions = this.getSignInOptions_();
299299

300300
for (var i = 0; i < signInOptions.length; i++) {
301-
if (signInOptions[i]['provider'] === firebaseui.auth.idp.EMAIL_PROVIDER_ID
302-
&& signInOptions[i]['requireDisplayName'] !== undefined) {
303-
return /** @type {boolean} */ (signInOptions[i]['requireDisplayName']);
301+
//if (signInOptions[i]['provider'] == firebase.auth.EmailAuthProvider.PROVIDER_ID
302+
if (signInOptions[i]['provider'] == 'password'
303+
&& signInOptions[i]['requireDisplayName'] !== undefined) {
304+
return /** @type {boolean} */ (!!signInOptions[i]['requireDisplayName']);
304305
}
305306
}
306307
return true;

javascript/widgets/config_test.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,20 @@
1818

1919
goog.provide('firebaseui.auth.widget.ConfigTest');
2020

21+
goog.require('firebaseui.auth.AuthUI');
22+
goog.require('firebaseui.auth.CredentialHelper');
23+
goog.require('firebaseui.auth.PendingEmailCredential');
24+
goog.require('firebaseui.auth.acClient');
25+
goog.require('firebaseui.auth.idp');
26+
goog.require('firebaseui.auth.storage');
27+
goog.require('firebaseui.auth.widget.handler');
28+
goog.require('firebaseui.auth.widget.handler.common');
29+
30+
2131
goog.require('firebaseui.auth.util');
2232
goog.require('firebaseui.auth.widget.Config');
33+
34+
2335
goog.require('goog.testing');
2436
goog.require('goog.testing.PropertyReplacer');
2537
goog.require('goog.testing.jsunit');
@@ -242,27 +254,38 @@ function testGetTosUrl() {
242254
}
243255

244256

245-
function testRequiredDisplayNameShouldBeTrueByDefault() {
246-
assertTrue(config.getRequireDisplayName());
257+
function testRequireDisplayName_shouldBeTrueByDefault() {
258+
assertTrue(config.isDisplayNameRequired());
247259
}
248260

249261

250-
function testRequiredDisplayNameCanBeSet() {
262+
function testRequireDisplayName_canBeSet() {
251263
config.update('signInOptions', [
252264
{
253265
'provider': 'password',
254266
'requireDisplayName': true
255267
}
256268
]);
257-
assertTrue(config.getRequireDisplayName());
269+
assertTrue(config.isDisplayNameRequired());
258270

259271
config.update('signInOptions', [
260272
{
261273
'provider': 'password',
262274
'requireDisplayName': false
263275
}
264276
]);
265-
assertFalse(config.getRequireDisplayName());
277+
assertFalse(config.isDisplayNameRequired());
278+
}
279+
280+
281+
function testRequireDisplayName_isTrueWithNonBooleanArgs() {
282+
config.update('signInOptions', [
283+
{
284+
'provider': 'password',
285+
'requireDisplayName': 'a string'
286+
}
287+
]);
288+
assertTrue(config.isDisplayNameRequired());
266289
}
267290

268291

javascript/widgets/handler/passwordsignup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ firebaseui.auth.widget.handler.handlePasswordSignUp = function(
4848
// Render the UI.
4949
var component = new firebaseui.auth.ui.page.PasswordSignUp(
5050
app.getConfig().getTosUrl(),
51-
app.getConfig().getRequireDisplayName(),
51+
app.getConfig().isDisplayNameRequired(),
5252
// On submit.
5353
function() {
5454
firebaseui.auth.widget.handler.onSignUpSubmit_(app, component);
@@ -70,7 +70,7 @@ firebaseui.auth.widget.handler.handlePasswordSignUp = function(
7070
* @private
7171
*/
7272
firebaseui.auth.widget.handler.onSignUpSubmit_ = function(app, component) {
73-
var requireDisplayName = app.getConfig().getRequireDisplayName();
73+
var requireDisplayName = app.getConfig().isDisplayNameRequired();
7474

7575
// Check fields are valid.
7676
var email = component.checkAndGetEmail();

javascript/widgets/handler/passwordsignup_test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,34 @@ function testHandlePasswordSignUp_reset() {
8888
assertComponentDisposed();
8989
}
9090

91+
function testHandlePasswordSignUp_withoutDisplayName() {
92+
app.setConfig({
93+
'signInOptions': [
94+
{
95+
provider: 'password',
96+
requireDisplayName: false
97+
}]
98+
});
99+
firebaseui.auth.widget.handler.handlePasswordSignUp(
100+
app, container, passwordAccount.getEmail());
101+
assertPasswordSignUpPage();
102+
assertNull(getNameElement());
103+
goog.dom.forms.setValue(getNewPasswordElement(), '123123');
104+
submitForm();
105+
106+
// assert successful sign up without the updateProfile
107+
// being called
108+
testAuth.assertCreateUserWithEmailAndPassword(
109+
[passwordAccount.getEmail(), '123123'], function() {
110+
testAuth.setUser({
111+
'email': passwordAccount.getEmail(),
112+
'displayName': passwordAccount.getDisplayName()
113+
});
114+
return testAuth.currentUser;
115+
});
116+
testAuth.assertSignOut([]);
117+
}
118+
91119

92120
function testHandlePasswordSignUp_signInCallback() {
93121
// Provide a sign-in success callback.

0 commit comments

Comments
 (0)