Skip to content

Commit 551c76c

Browse files
authored
Release3.4 (#485)
* release3.4
1 parent 17e7556 commit 551c76c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+585
-448
lines changed

README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ Localized versions of the widget are available through the CDN. To use a localiz
6363
localized JS library instead of the default library:
6464

6565
```html
66-
<script src="https://www.gstatic.com/firebasejs/ui/3.3.0/firebase-ui-auth__{LANGUAGE_CODE}.js"></script>
67-
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/3.3.0/firebase-ui-auth.css" />
66+
<script src="https://www.gstatic.com/firebasejs/ui/3.4.0/firebase-ui-auth__{LANGUAGE_CODE}.js"></script>
67+
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/3.4.0/firebase-ui-auth.css" />
6868
```
6969

7070
where `{LANGUAGE_CODE}` is replaced by the code of the language you want. For example, the French
7171
version of the library is available at
72-
`https://www.gstatic.com/firebasejs/ui/3.3.0/firebase-ui-auth__fr.js`. The list of available
72+
`https://www.gstatic.com/firebasejs/ui/3.4.0/firebase-ui-auth__fr.js`. The list of available
7373
languages and their respective language codes can be found at [LANGUAGES.md](LANGUAGES.md).
7474

7575
Right-to-left languages also require the right-to-left version of the stylesheet, available at
76-
`https://www.gstatic.com/firebasejs/ui/3.3.0/firebase-ui-auth-rtl.css`, instead of the default
76+
`https://www.gstatic.com/firebasejs/ui/3.4.0/firebase-ui-auth-rtl.css`, instead of the default
7777
stylesheet. The supported right-to-left languages are Arabic (ar), Farsi (fa), and Hebrew (iw).
7878

7979
### Option 2: npm Module
@@ -192,10 +192,14 @@ for a more in-depth example, showcasing a Single Page Application mode.
192192
firebase.auth.PhoneAuthProvider.PROVIDER_ID,
193193
firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID
194194
],
195-
// Terms of service url.
195+
// tosUrl and privacyPolicyUrl accept either url string or a callback
196+
// function.
197+
// Terms of service url/callback.
196198
tosUrl: '<your-tos-url>',
197-
// Privacy policy url.
198-
privacyPolicyUrl: '<your-privacy-policy-url>'
199+
// Privacy policy url/callback.
200+
privacyPolicyUrl: function() {
201+
window.location.assign('<your-privacy-policy-url>');
202+
}
199203
};
200204
201205
// Initialize the FirebaseUI Widget using Firebase.
@@ -399,12 +403,18 @@ FirebaseUI supports the following configuration parameters.
399403
<tr>
400404
<td>tosUrl</td>
401405
<td>Yes</td>
402-
<td>The URL of the Terms of Service page.</td>
406+
<td>
407+
The URL of the Terms of Service page or a callback function to be invoked
408+
when Terms of Service link is clicked.
409+
</td>
403410
</tr>
404411
<tr>
405412
<td>privacyPolicyUrl</td>
406413
<td>Yes</td>
407-
<td>The URL of the privacy policy page.</td>
414+
<td>
415+
The URL of the Privacy Policy page or a callback function to be invoked
416+
when Privacy Policy link is clicked.
417+
</td>
408418
</tr>
409419
</tbody>
410420
</table>
@@ -802,10 +812,14 @@ FirebaseUI is displayed.
802812
},
803813
firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID
804814
],
805-
// Terms of service url.
815+
// tosUrl and privacyPolicyUrl accept either url string or a callback
816+
// function.
817+
// Terms of service url/callback.
806818
tosUrl: '<your-tos-url>',
807-
// Privacy policy url.
808-
privacyPolicyUrl: '<your-privacy-policy-url>'
819+
// Privacy policy url/callback.
820+
privacyPolicyUrl: function() {
821+
window.location.assign('<your-privacy-policy-url>');
822+
}
809823
};
810824
811825
var ui = new firebaseui.auth.AuthUI(firebase.auth());

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feature - Allows passing callbacks for Term of Service and Privacy Policy.

externs/firebaseui-externs.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,16 @@ firebaseui.auth.Config.prototype.signInSuccessUrl;
250250
firebaseui.auth.Config.prototype.siteName;
251251

252252
/**
253-
* The terms of service URL.
253+
* The terms of service URL/callback.
254254
*
255-
* @type {string|undefined}
255+
* @type {string|function()|undefined}
256256
*/
257257
firebaseui.auth.Config.prototype.tosUrl;
258258

259259
/**
260-
* The privacy policy URL.
260+
* The privacy policy URL/callback.
261261
*
262-
* @type {string|undefined}
262+
* @type {string|function()|undefined}
263263
*/
264264
firebaseui.auth.Config.prototype.privacyPolicyUrl;
265265

javascript/testing/util.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ var FakeUtil = function() {
3737
this.openerGoToUrl_ = null;
3838
this.closedWindow_ = null;
3939
this.popupUrl_ = null;
40+
this.openUrl_ = null;
41+
this.windowName_ = null;
4042
};
4143
goog.inherits(FakeUtil, Disposable);
4244

@@ -63,6 +65,10 @@ FakeUtil.prototype.install = function() {
6365
r.set(util, 'popup', function(url) {
6466
self.popupUrl_ = url;
6567
});
68+
r.set(util, 'open', function(url, windowName) {
69+
self.openUrl_ = url;
70+
self.windowName_ = windowName;
71+
});
6672
return this;
6773
};
6874

@@ -120,6 +126,19 @@ FakeUtil.prototype.assertOpenerGoTo = function(url) {
120126
};
121127

122128

129+
/**
130+
* Asserts the given URL is loaded in the given window.
131+
* @param {string} url The URL to be loaded.
132+
* @param {string} windowName The window name to be loaded into.
133+
*/
134+
FakeUtil.prototype.assertOpen = function(url, windowName) {
135+
assertEquals(url, this.openUrl_);
136+
assertEquals(windowName, this.windowName_);
137+
this.openUrl_ = null;
138+
this.windowName_ = null;
139+
};
140+
141+
123142
/**
124143
* Asserts a window is closed.
125144
* @param {!Window} window The closed window.

javascript/ui/element/tospptesthelper.js

Lines changed: 79 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ goog.provide('firebaseui.auth.ui.element.TosPpTestHelper');
2121
goog.setTestOnly('firebaseui.auth.ui.element.TosPpTestHelper');
2222

2323
goog.require('firebaseui.auth.ui.element');
24+
goog.require('goog.testing.events');
2425

2526

2627
goog.scope(function() {
@@ -37,60 +38,116 @@ goog.inherits(element.TosPpTestHelper, element.ElementTestHelper);
3738

3839
/** @override */
3940
element.TosPpTestHelper.prototype.resetState = function() {
41+
this.tosLinkClicked_ = false;
42+
this.privacyPolicyLinkClicked_ = false;
4043
};
4144

4245

43-
/** Asserts the full message of ToS and Privacy Policy is displayed. */
46+
/** Handler for ToS link click event. */
47+
element.TosPpTestHelper.prototype.onTosLinkClick = function() {
48+
this.tosLinkClicked_ = true;
49+
};
50+
51+
52+
/** Handler for Privacy Policy link click event. */
53+
element.TosPpTestHelper.prototype.onPpLinkClick = function() {
54+
this.privacyPolicyLinkClicked_ = true;
55+
};
56+
57+
58+
/**
59+
* Asserts the full message of ToS and Privacy Policy is displayed.
60+
* @param {?function()|undefined} tosCallback The ToS callback.
61+
* @param {?function()|undefined} privacyPolicyCallback The Privacy Policy
62+
* callback.
63+
*/
4464
element.TosPpTestHelper.prototype.assertFullMessage = function(
45-
tosUrl, privacyPolicyUrl) {
65+
tosCallback, privacyPolicyCallback) {
4666
var element = this.component.getTosPpElement();
47-
if (!tosUrl && !privacyPolicyUrl) {
67+
if (!tosCallback && !privacyPolicyCallback) {
4868
assertNull(element);
4969
} else {
5070
assertTrue(element.classList.contains('firebaseui-tospp-full-message'));
51-
assertEquals(tosUrl, this.component.getTosLinkElement().href);
52-
assertEquals(privacyPolicyUrl, this.component.getPpLinkElement().href);
71+
this.assertTosLinkClicked_();
72+
this.assertPpLinkClicked_();
5373
}
5474
};
5575

5676

57-
/** Asserts the footer of ToS and Privacy Policy links is displayed. */
77+
/**
78+
* Asserts the footer of ToS and Privacy Policy links is displayed.
79+
* @param {?function()|undefined} tosCallback The ToS callback.
80+
* @param {?function()|undefined} privacyPolicyCallback The Privacy Policy
81+
* callback.
82+
*/
5883
element.TosPpTestHelper.prototype.assertFooter = function(
59-
tosUrl, privacyPolicyUrl) {
84+
tosCallback, privacyPolicyCallback) {
6085
var element = this.component.getTosPpListElement();
61-
if (!tosUrl && !privacyPolicyUrl) {
86+
if (!tosCallback && !privacyPolicyCallback) {
6287
assertNull(element);
6388
} else {
6489
assertTrue(element.classList.contains('firebaseui-tos-list'));
65-
assertEquals(tosUrl, this.component.getTosLinkElement().href);
66-
assertEquals(privacyPolicyUrl, this.component.getPpLinkElement().href);
90+
this.assertTosLinkClicked_();
91+
this.assertPpLinkClicked_();
6792
}
6893
};
6994

7095

71-
/** Asserts the full message of ToS and Privacy Policy and a notice to the user
72-
* about SMS rates for phone authentication are displayed. */
96+
/**
97+
* Asserts the full message of ToS and Privacy Policy and a notice to the user
98+
* about SMS rates for phone authentication are displayed.
99+
* @param {?function()|undefined} tosCallback The ToS callback.
100+
* @param {?function()|undefined} privacyPolicyCallback The Privacy Policy
101+
* callback.
102+
*/
73103
element.TosPpTestHelper.prototype.assertPhoneFullMessage = function(
74-
tosUrl, privacyPolicyUrl) {
104+
tosCallback, privacyPolicyCallback) {
75105
var element = this.component.getTosPpElement();
76106
assertTrue(element.classList.contains('firebaseui-phone-tos'));
77-
if (!tosUrl && !privacyPolicyUrl) {
107+
if (!tosCallback && !privacyPolicyCallback) {
78108
assertNull(this.component.getTosLinkElement());
79109
assertNull(this.component.getPpLinkElement());
80110
} else {
81-
assertEquals(tosUrl, this.component.getTosLinkElement().href);
82-
assertEquals(privacyPolicyUrl, this.component.getPpLinkElement().href);
111+
this.assertTosLinkClicked_();
112+
this.assertPpLinkClicked_();
83113
}
84114
};
85115

86116

87-
/** Asserts a notice to the user about SMS rates for phone authentication
88-
* and the link of ToS and Privacy Policy are displayed. */
117+
/**
118+
* Asserts a notice to the user about SMS rates for phone authentication
119+
* and the link of ToS and Privacy Policy are displayed.
120+
* @param {?function()|undefined} tosCallback The ToS callback.
121+
* @param {?function()|undefined} privacyPolicyCallback The Privacy Policy
122+
* callback.
123+
*/
89124
element.TosPpTestHelper.prototype.assertPhoneFooter = function(
90-
tosUrl, privacyPolicyUrl) {
125+
tosCallback, privacyPolicyCallback) {
91126
var element = this.component.getTosPpElement();
92127
assertTrue(element.classList.contains('firebaseui-phone-sms-notice'));
93-
this.assertFooter(tosUrl, privacyPolicyUrl);
128+
this.assertFooter(tosCallback, privacyPolicyCallback);
129+
};
130+
131+
132+
/**
133+
* Asserts the onClick callback is triggered when ToS link element is clicked.
134+
* @private
135+
*/
136+
element.TosPpTestHelper.prototype.assertTosLinkClicked_ = function() {
137+
assertFalse(this.tosLinkClicked_);
138+
goog.testing.events.fireClickSequence(this.component.getTosLinkElement());
139+
assertTrue(this.tosLinkClicked_);
140+
};
141+
142+
143+
/**
144+
* Asserts the onClick callback is triggered when Pp link element is clicked.
145+
* @private
146+
*/
147+
element.TosPpTestHelper.prototype.assertPpLinkClicked_ = function() {
148+
assertFalse(this.privacyPolicyLinkClicked_);
149+
goog.testing.events.fireClickSequence(this.component.getPpLinkElement());
150+
assertTrue(this.privacyPolicyLinkClicked_);
94151
};
95152

96153

@@ -103,11 +160,13 @@ element.TosPpTestHelper.prototype.testGetTosPpElement_ = function() {
103160
/** @private */
104161
element.TosPpTestHelper.prototype.testGetTosLinkElement_ = function() {
105162
assertNotNull(this.component.getTosLinkElement());
163+
this.assertTosLinkClicked_();
106164
};
107165

108166

109167
/** @private */
110168
element.TosPpTestHelper.prototype.testGetPpLinkElement_ = function() {
111169
assertNotNull(this.component.getPpLinkElement());
170+
this.assertPpLinkClicked_();
112171
};
113172
});

javascript/ui/page/base.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ goog.require('firebaseui.auth.ui.element');
2525
goog.require('firebaseui.auth.ui.element.dialog');
2626
goog.require('firebaseui.auth.ui.element.infoBar');
2727
goog.require('firebaseui.auth.ui.element.progressDialog');
28+
goog.require('firebaseui.auth.ui.element.tospp');
2829
goog.require('firebaseui.auth.ui.mdl');
2930
goog.require('goog.dom');
3031
goog.require('goog.dom.classlist');
@@ -159,6 +160,24 @@ firebaseui.auth.ui.page.Base.prototype.enterDocument = function() {
159160
{
160161
'pageId': this.getPageId()
161162
}));
163+
// If tos/pp element is available, sets the onClick handler when onClick
164+
// callbacks are provided.
165+
if (this.getTosLinkElement() && this.injectedData_.tosCallback) {
166+
var tosCallback =
167+
/** @type {function()} */ (this.injectedData_.tosCallback);
168+
firebaseui.auth.ui.element.listenForActionEvent(
169+
this, this.getTosLinkElement(), function(e) {
170+
tosCallback();
171+
});
172+
}
173+
if (this.getPpLinkElement() && this.injectedData_.privacyPolicyCallback) {
174+
var privacyPolicyCallback =
175+
/** @type {function()} */ (this.injectedData_.privacyPolicyCallback);
176+
firebaseui.auth.ui.element.listenForActionEvent(
177+
this, this.getPpLinkElement(), function(e) {
178+
privacyPolicyCallback();
179+
});
180+
}
162181
};
163182

164183

@@ -375,5 +394,15 @@ goog.mixin(
375394
dismissDialog:
376395
firebaseui.auth.ui.element.dialog.dismissDialog,
377396
getDialogElement:
378-
firebaseui.auth.ui.element.dialog.getDialogElement
397+
firebaseui.auth.ui.element.dialog.getDialogElement,
398+
399+
// For ToS and Privacy Policy.
400+
getTosPpElement:
401+
firebaseui.auth.ui.element.tospp.getTosPpElement,
402+
getTosLinkElement:
403+
firebaseui.auth.ui.element.tospp.getTosLinkElement,
404+
getPpLinkElement:
405+
firebaseui.auth.ui.element.tospp.getPpLinkElement,
406+
getTosPpListElement:
407+
firebaseui.auth.ui.element.tospp.getTosPpListElement
379408
});

0 commit comments

Comments
 (0)