Skip to content

Commit a8e9910

Browse files
committed
Support InteractiveAuth based registration
Passes in a function to make a register URL rather than just passing in the URL base
1 parent bb4d8ee commit a8e9910

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

‎src/vector/index.js‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2015, 2016 OpenMarket Ltd
3+
Copyright 2017 Vector Creations Ltd
34
45
Licensed under the Apache License, Version 2.0 (the "License");
56
you may not use this file except in compliance with the License.
@@ -147,16 +148,30 @@ var onNewScreen = function(screen) {
147148
// If we're in electron, we should never pass through a file:// URL otherwise
148149
// the identity server will try to 302 the browser to it, which breaks horribly.
149150
// so in that instance, hardcode to use riot.im/app for now instead.
150-
var makeRegistrationUrl = function() {
151+
var makeRegistrationUrl = function(params) {
152+
let url;
151153
if (window.location.protocol === "file:") {
152-
return 'https://riot.im/app/#/register';
154+
url = 'https://riot.im/app/#/register';
155+
} else {
156+
url = (
157+
window.location.protocol + '//' +
158+
window.location.host +
159+
window.location.pathname +
160+
'#/register'
161+
);
153162
}
154-
else {
155-
return window.location.protocol + '//' +
156-
window.location.host +
157-
window.location.pathname +
158-
'#/register';
163+
164+
const keys = Object.keys(params);
165+
for (let i = 0; i < keys.length; ++i) {
166+
if (i == 0) {
167+
url += '?';
168+
} else {
169+
url += '&';
170+
}
171+
const k = keys[i];
172+
url += k + '=' + encodeURIComponent(params[k]);
159173
}
174+
return url;
160175
}
161176

162177
window.addEventListener('hashchange', onHashChange);
@@ -258,7 +273,7 @@ async function loadApp() {
258273
window.matrixChat = ReactDOM.render(
259274
<MatrixChat
260275
onNewScreen={onNewScreen}
261-
registrationUrl={makeRegistrationUrl()}
276+
makeRegistrationUrl={makeRegistrationUrl}
262277
ConferenceHandler={VectorConferenceHandler}
263278
config={configJson}
264279
realQueryParams={params}

0 commit comments

Comments
 (0)