This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/initializers/auth-complete.js
2020-03-12 13:29:55 -04:00

24 lines
617 B
JavaScript

import { next } from "@ember/runloop";
export default {
name: "auth-complete",
after: "inject-objects",
initialize(container) {
let lastAuthResult;
if (document.getElementById("data-authentication")) {
// Happens for full screen logins
lastAuthResult = document.getElementById("data-authentication").dataset
.authenticationData;
}
if (lastAuthResult) {
const router = container.lookup("router:main");
router.one("didTransition", () => {
next(() =>
Discourse.authenticationComplete(JSON.parse(lastAuthResult))
);
});
}
}
};