From d76adfbb7f5ab3ae6a61febced35a79c3ed51b48 Mon Sep 17 00:00:00 2001 From: Daniel Borkan Date: Tue, 9 Feb 2016 16:16:29 -0500 Subject: [PATCH 1/2] Fix v1 invites (briefly broke due to Quiver changes) --- src/generic_ui/scripts/ui.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/generic_ui/scripts/ui.ts b/src/generic_ui/scripts/ui.ts index 87d0d6d421..9d5cf5f74a 100644 --- a/src/generic_ui/scripts/ui.ts +++ b/src/generic_ui/scripts/ui.ts @@ -536,7 +536,15 @@ export class UserInterface implements ui_constants.UiApi { var token = invite.substr(invite.lastIndexOf('/') + 1); // Removes any non base64 characters that may appear, e.g. "%E2%80%8E" token = token.match("[A-Za-z0-9+/=_]+")[0]; - return JSON.parse(atob(token)); + var parsedObj = JSON.parse(atob(token)); + return { + v: 1, + // For v1 invites networkData contains a single string, also + // called networkData. + networkData: parsedObj.networkData.networkData, + networkName: parsedObj.networkName, + userName: parsedObj.userName + }; } } catch(e) { return null; From f3d3adcdccf7043d8dbe99ab0543f3a8d834c428 Mon Sep 17 00:00:00 2001 From: Daniel Borkan Date: Tue, 9 Feb 2016 16:41:34 -0500 Subject: [PATCH 2/2] Fix invite parsing for Cloud --- src/generic_ui/scripts/ui.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/generic_ui/scripts/ui.ts b/src/generic_ui/scripts/ui.ts index 9d5cf5f74a..7c7a676215 100644 --- a/src/generic_ui/scripts/ui.ts +++ b/src/generic_ui/scripts/ui.ts @@ -537,11 +537,15 @@ export class UserInterface implements ui_constants.UiApi { // Removes any non base64 characters that may appear, e.g. "%E2%80%8E" token = token.match("[A-Za-z0-9+/=_]+")[0]; var parsedObj = JSON.parse(atob(token)); + var networkData = parsedObj.networkData; + if (typeof networkData === 'object' && networkData.networkData) { + // Firebase invites have a nested networkData string within a + // networkData object. TODO: move Firebase to use v2 invites. + networkData = networkData.networkData; + } return { v: 1, - // For v1 invites networkData contains a single string, also - // called networkData. - networkData: parsedObj.networkData.networkData, + networkData: networkData, networkName: parsedObj.networkName, userName: parsedObj.userName };