Skip to content

Commit 0997040

Browse files
author
Josh Crowther
authored
5.0.0 Breaking Changes (#741)
All breaking changes for the 5.0.0 release.
1 parent 7edf649 commit 0997040

Some content is hidden

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

81 files changed

+4311
-1209
lines changed

packages/auth-types/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface User extends UserInfo {
2222
emailVerified: boolean;
2323
getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
2424
getIdToken(forceRefresh?: boolean): Promise<any>;
25-
getToken(forceRefresh?: boolean): Promise<any>;
2625
isAnonymous: boolean;
2726
linkAndRetrieveDataWithCredential(credential: AuthCredential): Promise<any>;
2827
linkWithCredential(credential: AuthCredential): Promise<any>;
@@ -239,6 +238,10 @@ export interface OAuthCredential extends AuthCredential {
239238
secret?: string;
240239
}
241240

241+
export interface AuthSettings {
242+
appVerificationDisabledForTesting: boolean;
243+
}
244+
242245
export class FirebaseAuth {
243246
private constructor();
244247

@@ -263,6 +266,7 @@ export class FirebaseAuth {
263266
isSignInWithEmailLink(emailLink: string): boolean;
264267
getRedirectResult(): Promise<any>;
265268
languageCode: string | null;
269+
settings: AuthSettings;
266270
onAuthStateChanged(
267271
nextOrObserver: Observer<any, any> | ((a: User | null) => any),
268272
error?: (a: Error) => any,
@@ -301,6 +305,7 @@ export class FirebaseAuth {
301305
signInWithPopup(provider: AuthProvider): Promise<any>;
302306
signInWithRedirect(provider: AuthProvider): Promise<any>;
303307
signOut(): Promise<any>;
308+
updateCurrentUser(user: User | null): Promise<any>;
304309
useDeviceLanguage(): any;
305310
verifyPasswordResetCode(code: string): Promise<any>;
306311
}

packages/auth/demo/public/index.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@
161161

162162
<div class="tab-content">
163163
<div class="tab-pane active" id="auth-section">
164+
<!-- Development mode APIs -->
165+
<div class="group">Development mode APIs</div>
166+
<form class="form form-bordered no-submit">
167+
<div class="btn-group radio-block" id="enable-app-verification-selection"
168+
data-toggle="buttons">
169+
<label class="btn btn-primary active">
170+
<input type="radio" name="enable-app-verification" value="Yes"
171+
autocomplete="off" checked> Enable App Verification
172+
</label>
173+
<label class="btn btn-primary">
174+
<input type="radio" name="enable-app-verification" value="No"
175+
autocomplete="off"> Disable App Verification
176+
</label>
177+
</div>
178+
<button class="btn btn-block btn-primary"
179+
id="apply-auth-settings-change">Apply settings change</button>
180+
</form>
181+
164182
<!-- Worker tests -->
165183
<div class="group">Web Worker Testing</div>
166184
<form class="form form-bordered no-submit">
@@ -334,6 +352,21 @@
334352
Fetch Providers For Email
335353
</button>
336354
</form>
355+
356+
<!-- Update Current User -->
357+
<div class="group">Update Current User</div>
358+
<form class="form form-bordered no-submit">
359+
<button class="btn btn-block btn-primary"
360+
id="copy-active-user">
361+
Copy Active User to Temp Auth
362+
</button>
363+
</form>
364+
<form class="form form-bordered no-submit">
365+
<button class="btn btn-block btn-primary"
366+
id="copy-last-user">
367+
Copy Last User to Auth
368+
</button>
369+
</form>
337370
</div>
338371
<div class="tab-pane" id="user-section">
339372
<!-- Profile updates -->

packages/auth/demo/public/script.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
var app = null;
2222
var auth = null;
23+
var tempApp = null;
24+
var tempAuth = null;
2325
var currentTab = null;
2426
var lastUser = null;
2527
var applicationVerifier = null;
@@ -1279,6 +1281,39 @@ function onRunServiceWorkTests() {
12791281
}
12801282

12811283

1284+
/** Copy current user of auth to tempAuth. */
1285+
function onCopyActiveUser() {
1286+
tempAuth.updateCurrentUser(activeUser()).then(function() {
1287+
alertSuccess('Copied active user to temp Auth');
1288+
}, function(error) {
1289+
alertError('Error: ' + error.code);
1290+
});
1291+
}
1292+
1293+
1294+
/** Copy last user to auth. */
1295+
function onCopyLastUser() {
1296+
// If last user is null, NULL_USER error will be thrown.
1297+
auth.updateCurrentUser(lastUser).then(function() {
1298+
alertSuccess('Copied last user to Auth');
1299+
}, function(error) {
1300+
alertError('Error: ' + error.code);
1301+
});
1302+
}
1303+
1304+
1305+
/** Applies selected auth settings change. */
1306+
function onApplyAuthSettingsChange() {
1307+
try {
1308+
auth.settings.appVerificationDisabledForTesting =
1309+
$("input[name=enable-app-verification]:checked").val() == 'No';
1310+
alertSuccess('Auth settings changed');
1311+
} catch (error) {
1312+
alertError('Error: ' + error.code);
1313+
}
1314+
}
1315+
1316+
12821317
/**
12831318
* Initiates the application by setting event listeners on the various buttons.
12841319
*/
@@ -1287,6 +1322,12 @@ function initApp(){
12871322
app = firebase.initializeApp(config);
12881323
auth = app.auth();
12891324

1325+
tempApp = firebase.initializeApp({
1326+
'apiKey': config['apiKey'],
1327+
'authDomain': config['authDomain']
1328+
}, auth['app']['name'] + '-temp');
1329+
tempAuth = tempApp.auth();
1330+
12901331
// Listen to reCAPTCHA config togglers.
12911332
initRecaptchaToggle(function(size) {
12921333
clearApplicationVerifier();
@@ -1329,6 +1370,15 @@ function initApp(){
13291370
});
13301371
}
13311372

1373+
if (tempAuth.onAuthStateChanged) {
1374+
tempAuth.onAuthStateChanged(function(user) {
1375+
if (user) {
1376+
log('user state change on temp Auth detect: ' + JSON.stringify(user));
1377+
alertSuccess('user state change on temp Auth detect: ' + user.uid);
1378+
}
1379+
});
1380+
}
1381+
13321382
// We check for redirect result to refresh user's data.
13331383
auth.getRedirectResult().then(function(response) {
13341384
refreshUserData();
@@ -1443,6 +1493,10 @@ function initApp(){
14431493

14441494
$('#run-web-worker-tests').click(onRunWebWorkTests);
14451495
$('#run-service-worker-tests').click(onRunServiceWorkTests);
1496+
$('#copy-active-user').click(onCopyActiveUser);
1497+
$('#copy-last-user').click(onCopyLastUser);
1498+
1499+
$('#apply-auth-settings-change').click(onApplyAuthSettingsChange);
14461500
}
14471501

14481502
$(initApp);

packages/auth/src/args.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ goog.provide('fireauth.args.Argument');
2424

2525
goog.require('fireauth.Auth');
2626
goog.require('fireauth.AuthError');
27+
goog.require('fireauth.AuthUser');
2728
goog.require('fireauth.authenum.Error');
2829

2930

@@ -365,6 +366,25 @@ fireauth.args.firebaseAuth = function(opt_optional) {
365366
};
366367

367368

369+
/**
370+
* Specifies an instance of Firebase User.
371+
* @param {?boolean=} opt_optional Whether or not this argument is optional.
372+
* Defaults to false.
373+
* @return {!fireauth.args.Argument}
374+
*/
375+
fireauth.args.firebaseUser = function(opt_optional) {
376+
return /** @type {!fireauth.args.Argument} */ ({
377+
name: 'user',
378+
typeLabel: 'an instance of Firebase User',
379+
optional: !!opt_optional,
380+
validator: /** @type {function(!fireauth.AuthUser) : boolean} */ (
381+
function(user) {
382+
return !!(user && user instanceof fireauth.AuthUser);
383+
})
384+
});
385+
};
386+
387+
368388
/**
369389
* Specifies an instance of Firebase App.
370390
* @param {?boolean=} opt_optional Whether or not this argument is optional.

0 commit comments

Comments
 (0)