[next] Auth Callback + Chunking (#2139)

* feat: added new auth-callback

* fix: removed unused polyfill code

* fix: fixed missed intersection observer

* feat: enabled vendor chunks

* fix: fix some issues with chunk splitting

* fix: added intersection-observer to app polyfill

* fix: fixed test

* fix: removed lodash plugin which caused issue in prod

* chore: access_token -> accessToken

* feat: Show social login errors

* fix: lint + add test

* fix: restore width after facebook social login
This commit is contained in:
Wyatt Johnson
2019-01-11 15:31:24 +01:00
committed by Kiwi
parent 0e941222c5
commit 94eb72a9bf
42 changed files with 880 additions and 277 deletions
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>Talk - Auth Callback</title>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no">
</head>
<body></body>
</html>
+38
View File
@@ -0,0 +1,38 @@
import { authRedirectBackTo as key } from "talk-framework/helpers/storageKeys";
try {
// Pull the redirection
const value = sessionStorage.getItem(key);
if (!value) {
throw new Error(`${key} session storage key not set`);
}
if (process.env.NODE_ENV === "production") {
// Remove the redirect URL that we pulled from sessionStorage.
sessionStorage.removeItem(key);
}
// Parse the URL from the redirect parameter, and pull out the pathname.
const parser = document.createElement("a");
parser.href = value;
const redirectBackTo = parser.pathname + parser.search;
if (!redirectBackTo) {
throw new Error(`url stored in the ${key} session storage key was invalid`);
}
if (process.env.NODE_ENV !== "production") {
// Remove the redirect URL that we pulled from sessionStorage.
sessionStorage.removeItem(key);
}
// Now that we have a valid redirection URL, we should append the current
// hash that includes the credentials or errors from the callback.
const redirectBackToWithToken = redirectBackTo + location.hash;
// Send the user off to the redirection URL.
location.href = redirectBackToWithToken;
} catch (err) {
// Place the error message right into the document body.
document.body.appendChild(document.createTextNode(err.message));
}