Skip to content

changelog.txt update and added sign in handler cancel button #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
feature - Added ability to not require the display name in password sign up.
feature - Pass login_hint when a user needs to sign in with Google using a specific email.
fixed - Fixed account linking in recent versions of Firebase Auth.
fixed - Fixed "operation not supported" error for password providers in Cordova environment.
fixed - Display error when account lookup returns an unexpected error from the Auth backend.
fixed - Added back button in sign in handler page.
28 changes: 22 additions & 6 deletions javascript/ui/page/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ goog.require('goog.dom.selection');
* UI component for the user to enter their email.
* @param {function()} onEmailEnter Callback to invoke when enter key (or its
* equivalent) is detected.
* @param {function()} onCancelClick Callback to invoke when cancel button
* is clicked.
* @param {string=} opt_email The email to prefill.
* @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
* @constructor
* @extends {firebaseui.auth.ui.page.Base}
*/
firebaseui.auth.ui.page.SignIn = function(
onEmailEnter,
onCancelClick,
opt_email,
opt_domHelper) {
firebaseui.auth.ui.page.SignIn.base(
Expand All @@ -48,6 +51,7 @@ firebaseui.auth.ui.page.SignIn = function(
opt_domHelper,
'signIn');
this.onEmailEnter_ = onEmailEnter;
this.onCancelClick_ = onCancelClick;
};
goog.inherits(firebaseui.auth.ui.page.SignIn, firebaseui.auth.ui.page.Base);

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


/** @override */
firebaseui.auth.ui.page.SignIn.prototype.disposeInternal = function() {
this.onEmailEnter_ = null;
this.onCancelClick_ = null;
firebaseui.auth.ui.page.SignIn.base(this, 'disposeInternal');
};


/**
* Sets up the focus order and auto focus.
* @private
*/
firebaseui.auth.ui.page.SignIn.prototype.setupFocus_ = function() {
// Auto focus the email input and put the cursor at the end.
this.getEmailElement().focus();
goog.dom.selection.setCursorPosition(
this.getEmailElement(), (this.getEmailElement().value || '').length);
};


goog.mixin(
firebaseui.auth.ui.page.SignIn.prototype,
/** @lends {firebaseui.auth.ui.page.SignIn.prototype} */
Expand All @@ -92,6 +106,8 @@ goog.mixin(
// For form.
getSubmitElement:
firebaseui.auth.ui.element.form.getSubmitElement,
getSecondaryLinkElement:
firebaseui.auth.ui.element.form.getSecondaryLinkElement,
initFormElement:
firebaseui.auth.ui.element.form.initFormElement
});
12 changes: 11 additions & 1 deletion javascript/ui/page/signin_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ goog.setTestOnly('firebaseui.auth.ui.page.SignInTest');

goog.require('firebaseui.auth.ui.element');
goog.require('firebaseui.auth.ui.element.EmailTestHelper');
goog.require('firebaseui.auth.ui.element.FormTestHelper');
goog.require('firebaseui.auth.ui.element.InfoBarTestHelper');
goog.require('firebaseui.auth.ui.page.PageTestHelper');
goog.require('firebaseui.auth.ui.page.SignIn');
Expand All @@ -36,6 +37,11 @@ var root;
var component;
var emailTestHelper =
new firebaseui.auth.ui.element.EmailTestHelper().registerTests();
// Ignore form helper submit button click as they are already explicitly
// tested.
var formTestHelper = new firebaseui.auth.ui.element.FormTestHelper()
.excludeTests('testOnSubmitEnter_', 'testOnSubmitClick_')
.registerTests();
var infoBarTestHelper =
new firebaseui.auth.ui.element.InfoBarTestHelper().registerTests();

Expand All @@ -46,10 +52,14 @@ function setUp() {
component = new firebaseui.auth.ui.page.SignIn(
goog.bind(
firebaseui.auth.ui.element.EmailTestHelper.prototype.onEnter,
emailTestHelper));
emailTestHelper),
goog.bind(
firebaseui.auth.ui.element.FormTestHelper.prototype.onLinkClick,
formTestHelper));
component.render(root);
emailTestHelper.setComponent(component);
infoBarTestHelper.setComponent(component);
formTestHelper.setComponent(component);
}


Expand Down
2 changes: 0 additions & 2 deletions javascript/utils/idp.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ firebaseui.auth.idp.getAuthCredential = function(credentialObject) {
firebase.auth[firebaseui.auth.idp.AuthProviders[providerId]]) {
// Twitter special case.
if (credentialObject['secret'] && credentialObject['accessToken']) {
credentialObject['oauthToken'] = credentialObject['accessToken'];
credentialObject['oauthTokenSecret'] = credentialObject['secret'];
return firebase.auth[firebaseui.auth.idp.AuthProviders[providerId]]
.credential(credentialObject['accessToken'],
credentialObject['secret']);
Expand Down
10 changes: 10 additions & 0 deletions javascript/widgets/handler/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ firebaseui.auth.widget.handler.handleSignIn = function(
function() {
firebaseui.auth.widget.handler.onSignInEmailEnter_(app, component);
},
// On cancel.
function() {
// Downside is if only email auth provider is selected and
// accountchooser.com is disabled, the cancel button will do nothing.
// Future improvement would be to not display this button in that
// edge case.
component.dispose();
firebaseui.auth.widget.handler.common.handleSignInStart(
app, container, opt_email);
},
opt_email);
component.render(container);
// Set current UI component.
Expand Down
33 changes: 33 additions & 0 deletions javascript/widgets/handler/signin_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,39 @@ function testHandleSignIn() {
}


function testHandleSignIn_cancelButtonClick_multipleProviders() {
firebaseui.auth.widget.handler.handleSignIn(app, container);
assertSignInPage();
// Click cancel.
clickSecondaryLink();
// Provider sign in page should be rendered.
assertProviderSignInPage();
}


function testHandleSignIn_cancelButtonClick_emailProviderOnly() {
// Simulate existing password account selected in accountchooser.com.
testAc.setSelectedAccount(passwordAccount);
app.updateConfig('signInOptions', ['password']);
firebaseui.auth.widget.handler.handleSignIn(
app, container, passwordAccount.getEmail());
assertSignInPage();
// Click cancel.
clickSecondaryLink();
// handleSignInWithEmail should be called underneath.
// If accountchoose.com is enabled, page will redirect to it.
testAuth.assertFetchProvidersForEmail(
[passwordAccount.getEmail()],
['password']);
testAuth.process().then(function() {
assertPasswordSignInPage();
var emailInput = getEmailElement();
assertEquals(
passwordAccount.getEmail(), goog.dom.forms.getValue(emailInput));
});
}


function testHandleSignIn_accountLookupError() {
// Test when account lookup throws an error.
var expectedError = {
Expand Down
1 change: 1 addition & 0 deletions soy/pages.soy
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
</div>
<div class="{css firebaseui-card-footer}">
<div class="{css firebaseui-form-actions}">
{call firebaseui.auth.soy2.element.cancelButton /}
{call firebaseui.auth.soy2.element.submitButton /}
</div>
</div>
Expand Down