Skip to content

Commit de0b9c4

Browse files
changelog.txt update and added sign in handler cancel button (#127)
* Updated changelog.txt with latest changes before pushing a release. Added a cancel button in the signin handler. * Removed unused lines in javascript/utils/idp.js.
1 parent 95b6f4d commit de0b9c4

File tree

7 files changed

+83
-9
lines changed

7 files changed

+83
-9
lines changed

changelog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
feature - Added ability to not require the display name in password sign up.
2+
feature - Pass login_hint when a user needs to sign in with Google using a specific email.
3+
fixed - Fixed account linking in recent versions of Firebase Auth.
4+
fixed - Fixed "operation not supported" error for password providers in Cordova environment.
5+
fixed - Display error when account lookup returns an unexpected error from the Auth backend.
6+
fixed - Added back button in sign in handler page.

javascript/ui/page/signin.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ goog.require('goog.dom.selection');
3131
* UI component for the user to enter their email.
3232
* @param {function()} onEmailEnter Callback to invoke when enter key (or its
3333
* equivalent) is detected.
34+
* @param {function()} onCancelClick Callback to invoke when cancel button
35+
* is clicked.
3436
* @param {string=} opt_email The email to prefill.
3537
* @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
3638
* @constructor
3739
* @extends {firebaseui.auth.ui.page.Base}
3840
*/
3941
firebaseui.auth.ui.page.SignIn = function(
4042
onEmailEnter,
43+
onCancelClick,
4144
opt_email,
4245
opt_domHelper) {
4346
firebaseui.auth.ui.page.SignIn.base(
@@ -48,6 +51,7 @@ firebaseui.auth.ui.page.SignIn = function(
4851
opt_domHelper,
4952
'signIn');
5053
this.onEmailEnter_ = onEmailEnter;
54+
this.onCancelClick_ = onCancelClick;
5155
};
5256
goog.inherits(firebaseui.auth.ui.page.SignIn, firebaseui.auth.ui.page.Base);
5357

@@ -56,23 +60,33 @@ goog.inherits(firebaseui.auth.ui.page.SignIn, firebaseui.auth.ui.page.Base);
5660
firebaseui.auth.ui.page.SignIn.prototype.enterDocument = function() {
5761
this.initEmailElement(this.onEmailEnter_);
5862
var self = this;
59-
// Handle a click on the submit button.
60-
this.initFormElement(this.onEmailEnter_);
61-
// Auto focus the email input and put the cursor at the end.
62-
this.getEmailElement().focus();
63-
goog.dom.selection.setCursorPosition(
64-
this.getEmailElement(), (this.getEmailElement().value || '').length);
63+
// Handle a click on the submit button or cancel button.
64+
this.initFormElement(this.onEmailEnter_, this.onCancelClick_);
65+
this.setupFocus_();
6566
firebaseui.auth.ui.page.SignIn.base(this, 'enterDocument');
6667
};
6768

6869

6970
/** @override */
7071
firebaseui.auth.ui.page.SignIn.prototype.disposeInternal = function() {
7172
this.onEmailEnter_ = null;
73+
this.onCancelClick_ = null;
7274
firebaseui.auth.ui.page.SignIn.base(this, 'disposeInternal');
7375
};
7476

7577

78+
/**
79+
* Sets up the focus order and auto focus.
80+
* @private
81+
*/
82+
firebaseui.auth.ui.page.SignIn.prototype.setupFocus_ = function() {
83+
// Auto focus the email input and put the cursor at the end.
84+
this.getEmailElement().focus();
85+
goog.dom.selection.setCursorPosition(
86+
this.getEmailElement(), (this.getEmailElement().value || '').length);
87+
};
88+
89+
7690
goog.mixin(
7791
firebaseui.auth.ui.page.SignIn.prototype,
7892
/** @lends {firebaseui.auth.ui.page.SignIn.prototype} */
@@ -92,6 +106,8 @@ goog.mixin(
92106
// For form.
93107
getSubmitElement:
94108
firebaseui.auth.ui.element.form.getSubmitElement,
109+
getSecondaryLinkElement:
110+
firebaseui.auth.ui.element.form.getSecondaryLinkElement,
95111
initFormElement:
96112
firebaseui.auth.ui.element.form.initFormElement
97113
});

javascript/ui/page/signin_test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ goog.setTestOnly('firebaseui.auth.ui.page.SignInTest');
2121

2222
goog.require('firebaseui.auth.ui.element');
2323
goog.require('firebaseui.auth.ui.element.EmailTestHelper');
24+
goog.require('firebaseui.auth.ui.element.FormTestHelper');
2425
goog.require('firebaseui.auth.ui.element.InfoBarTestHelper');
2526
goog.require('firebaseui.auth.ui.page.PageTestHelper');
2627
goog.require('firebaseui.auth.ui.page.SignIn');
@@ -36,6 +37,11 @@ var root;
3637
var component;
3738
var emailTestHelper =
3839
new firebaseui.auth.ui.element.EmailTestHelper().registerTests();
40+
// Ignore form helper submit button click as they are already explicitly
41+
// tested.
42+
var formTestHelper = new firebaseui.auth.ui.element.FormTestHelper()
43+
.excludeTests('testOnSubmitEnter_', 'testOnSubmitClick_')
44+
.registerTests();
3945
var infoBarTestHelper =
4046
new firebaseui.auth.ui.element.InfoBarTestHelper().registerTests();
4147

@@ -46,10 +52,14 @@ function setUp() {
4652
component = new firebaseui.auth.ui.page.SignIn(
4753
goog.bind(
4854
firebaseui.auth.ui.element.EmailTestHelper.prototype.onEnter,
49-
emailTestHelper));
55+
emailTestHelper),
56+
goog.bind(
57+
firebaseui.auth.ui.element.FormTestHelper.prototype.onLinkClick,
58+
formTestHelper));
5059
component.render(root);
5160
emailTestHelper.setComponent(component);
5261
infoBarTestHelper.setComponent(component);
62+
formTestHelper.setComponent(component);
5363
}
5464

5565

javascript/utils/idp.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ firebaseui.auth.idp.getAuthCredential = function(credentialObject) {
6464
firebase.auth[firebaseui.auth.idp.AuthProviders[providerId]]) {
6565
// Twitter special case.
6666
if (credentialObject['secret'] && credentialObject['accessToken']) {
67-
credentialObject['oauthToken'] = credentialObject['accessToken'];
68-
credentialObject['oauthTokenSecret'] = credentialObject['secret'];
6967
return firebase.auth[firebaseui.auth.idp.AuthProviders[providerId]]
7068
.credential(credentialObject['accessToken'],
7169
credentialObject['secret']);

javascript/widgets/handler/signin.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ firebaseui.auth.widget.handler.handleSignIn = function(
4242
function() {
4343
firebaseui.auth.widget.handler.onSignInEmailEnter_(app, component);
4444
},
45+
// On cancel.
46+
function() {
47+
// Downside is if only email auth provider is selected and
48+
// accountchooser.com is disabled, the cancel button will do nothing.
49+
// Future improvement would be to not display this button in that
50+
// edge case.
51+
component.dispose();
52+
firebaseui.auth.widget.handler.common.handleSignInStart(
53+
app, container, opt_email);
54+
},
4555
opt_email);
4656
component.render(container);
4757
// Set current UI component.

javascript/widgets/handler/signin_test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,39 @@ function testHandleSignIn() {
7777
}
7878

7979

80+
function testHandleSignIn_cancelButtonClick_multipleProviders() {
81+
firebaseui.auth.widget.handler.handleSignIn(app, container);
82+
assertSignInPage();
83+
// Click cancel.
84+
clickSecondaryLink();
85+
// Provider sign in page should be rendered.
86+
assertProviderSignInPage();
87+
}
88+
89+
90+
function testHandleSignIn_cancelButtonClick_emailProviderOnly() {
91+
// Simulate existing password account selected in accountchooser.com.
92+
testAc.setSelectedAccount(passwordAccount);
93+
app.updateConfig('signInOptions', ['password']);
94+
firebaseui.auth.widget.handler.handleSignIn(
95+
app, container, passwordAccount.getEmail());
96+
assertSignInPage();
97+
// Click cancel.
98+
clickSecondaryLink();
99+
// handleSignInWithEmail should be called underneath.
100+
// If accountchoose.com is enabled, page will redirect to it.
101+
testAuth.assertFetchProvidersForEmail(
102+
[passwordAccount.getEmail()],
103+
['password']);
104+
testAuth.process().then(function() {
105+
assertPasswordSignInPage();
106+
var emailInput = getEmailElement();
107+
assertEquals(
108+
passwordAccount.getEmail(), goog.dom.forms.getValue(emailInput));
109+
});
110+
}
111+
112+
80113
function testHandleSignIn_accountLookupError() {
81114
// Test when account lookup throws an error.
82115
var expectedError = {

soy/pages.soy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
</div>
3838
<div class="{css firebaseui-card-footer}">
3939
<div class="{css firebaseui-form-actions}">
40+
{call firebaseui.auth.soy2.element.cancelButton /}
4041
{call firebaseui.auth.soy2.element.submitButton /}
4142
</div>
4243
</div>

0 commit comments

Comments
 (0)