Merge pull request #4335 from vector-im/rav/fix_token_redirect

onLoadCompleted is now onTokenLoginCompleted
This commit is contained in:
Richard van der Hoff 2017-06-19 09:06:17 +01:00 committed by GitHub
commit 563d1dc3f1
2 changed files with 15 additions and 17 deletions

View File

@ -216,18 +216,16 @@ function getConfig() {
return deferred.promise; return deferred.promise;
} }
function onLoadCompleted() { function onTokenLoginCompleted() {
// if we did a token login, we're now left with the token, hs and is // if we did a token login, we're now left with the token, hs and is
// url as query params in the url; a little nasty but let's redirect to // url as query params in the url; a little nasty but let's redirect to
// clear them. // clear them.
if (window.location.search) {
var parsedUrl = url.parse(window.location.href); var parsedUrl = url.parse(window.location.href);
parsedUrl.search = ""; parsedUrl.search = "";
var formatted = url.format(parsedUrl); var formatted = url.format(parsedUrl);
console.log("Redirecting to " + formatted + " to drop loginToken " + console.log("Redirecting to " + formatted + " to drop loginToken " +
"from queryparams"); "from queryparams");
window.location.href = formatted; window.location.href = formatted;
}
} }
async function loadApp() { async function loadApp() {
@ -288,7 +286,7 @@ async function loadApp() {
realQueryParams={params} realQueryParams={params}
startingFragmentQueryParams={fragparts.params} startingFragmentQueryParams={fragparts.params}
enableGuest={true} enableGuest={true}
onLoadCompleted={onLoadCompleted} onTokenLoginCompleted={onTokenLoginCompleted}
initialScreenAfterLogin={getScreenFromLocation(window.location)} initialScreenAfterLogin={getScreenFromLocation(window.location)}
defaultDeviceDisplayName={PlatformPeg.get().getDefaultDeviceDisplayName()} defaultDeviceDisplayName={PlatformPeg.get().getDefaultDeviceDisplayName()}
/>, />,

View File

@ -48,8 +48,8 @@ describe('loading:', function () {
// the mounted MatrixChat // the mounted MatrixChat
let matrixChat; let matrixChat;
// a promise which resolves when the MatrixChat calls onLoadCompleted // a promise which resolves when the MatrixChat calls onTokenLoginCompleted
let loadCompletePromise; let tokenLoginCompletePromise;
beforeEach(function() { beforeEach(function() {
test_utils.beforeEach(this); test_utils.beforeEach(this);
@ -100,8 +100,8 @@ describe('loading:', function () {
toString: function() { return this.search + this.hash; }, toString: function() { return this.search + this.hash; },
}; };
let loadCompleteDefer = q.defer(); let tokenLoginCompleteDefer = q.defer();
loadCompletePromise = loadCompleteDefer.promise; tokenLoginCompletePromise = tokenLoginCompleteDefer.promise;
function onNewScreen(screen) { function onNewScreen(screen) {
console.log(Date.now() + " newscreen "+screen); console.log(Date.now() + " newscreen "+screen);
@ -136,7 +136,7 @@ describe('loading:', function () {
realQueryParams={params} realQueryParams={params}
startingFragmentQueryParams={fragParts.params} startingFragmentQueryParams={fragParts.params}
enableGuest={true} enableGuest={true}
onLoadCompleted={loadCompleteDefer.resolve} onTokenLoginCompleted={tokenLoginCompleteDefer.resolve}
initialScreenAfterLogin={getScreenFromLocation(windowLocation)} initialScreenAfterLogin={getScreenFromLocation(windowLocation)}
makeRegistrationUrl={() => {throw new Error('Not implemented');}} makeRegistrationUrl={() => {throw new Error('Not implemented');}}
/>, parentDiv />, parentDiv
@ -517,12 +517,12 @@ describe('loading:', function () {
return httpBackend.flush(); return httpBackend.flush();
}).then(() => { }).then(() => {
// at this point, MatrixChat should fire onLoadCompleted, which // at this point, MatrixChat should fire onTokenLoginCompleted, which
// makes index.js reload the app. We're not going to attempt to // makes index.js reload the app. We're not going to attempt to
// simulate the reload - just check that things are left in the // simulate the reload - just check that things are left in the
// right state for the reloaded app. // right state for the reloaded app.
return loadCompletePromise; return tokenLoginCompletePromise;
}).then(() => { }).then(() => {
// check that the localstorage has been set up in such a way that // check that the localstorage has been set up in such a way that
// the reloaded app can pick up where we leave off. // the reloaded app can pick up where we leave off.