You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Use the current HS for guest login
Make sure that we use the homeserver from localstorage for guest regsistration, in preference to the default. Also rename the parameters for loadSession
This commit is contained in:
@@ -47,18 +47,18 @@ import dis from './dispatcher';
|
|||||||
* @param {boolean} opts.enableGuest: set to true to enable guest access tokens
|
* @param {boolean} opts.enableGuest: set to true to enable guest access tokens
|
||||||
* and auto-guest registrations.
|
* and auto-guest registrations.
|
||||||
*
|
*
|
||||||
* @params {string} opts.hsUrl: homeserver URL. Only used if enableGuest is
|
* @params {string} opts.guestHsUrl: homeserver URL. Only used if enableGuest is
|
||||||
* true; defines the HS to register against.
|
* true; defines the HS to register against.
|
||||||
*
|
*
|
||||||
* @params {string} opts.isUrl: homeserver URL. Only used if enableGuest is
|
* @params {string} opts.guestIsUrl: homeserver URL. Only used if enableGuest is
|
||||||
* true; defines the IS to use.
|
* true; defines the IS to use.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function loadSession(opts) {
|
export function loadSession(opts) {
|
||||||
const queryParams = opts.queryParams || {};
|
const queryParams = opts.queryParams || {};
|
||||||
let enableGuest = opts.enableGuest || false;
|
let enableGuest = opts.enableGuest || false;
|
||||||
const hsUrl = opts.hsUrl;
|
const guestHsUrl = opts.guestHsUrl;
|
||||||
const isUrl = opts.isUrl;
|
const guestIsUrl = opts.guestIsUrl;
|
||||||
|
|
||||||
if (queryParams.client_secret && queryParams.sid) {
|
if (queryParams.client_secret && queryParams.sid) {
|
||||||
// this happens during email validation: the email contains a link to the
|
// this happens during email validation: the email contains a link to the
|
||||||
@@ -68,7 +68,7 @@ export function loadSession(opts) {
|
|||||||
return q();
|
return q();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hsUrl) {
|
if (!guestHsUrl) {
|
||||||
console.warn("Cannot enable guest access: can't determine HS URL to use");
|
console.warn("Cannot enable guest access: can't determine HS URL to use");
|
||||||
enableGuest = false;
|
enableGuest = false;
|
||||||
}
|
}
|
||||||
@@ -81,8 +81,8 @@ export function loadSession(opts) {
|
|||||||
setLoggedIn({
|
setLoggedIn({
|
||||||
userId: queryParams.guest_user_id,
|
userId: queryParams.guest_user_id,
|
||||||
accessToken: queryParams.guest_access_token,
|
accessToken: queryParams.guest_access_token,
|
||||||
homeserverUrl: hsUrl,
|
homeserverUrl: guestHsUrl,
|
||||||
identityServerUrl: isUrl,
|
identityServerUrl: guestIsUrl,
|
||||||
guest: true,
|
guest: true,
|
||||||
});
|
});
|
||||||
return q();
|
return q();
|
||||||
@@ -93,7 +93,7 @@ export function loadSession(opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (enableGuest) {
|
if (enableGuest) {
|
||||||
return _registerAsGuest(hsUrl, isUrl);
|
return _registerAsGuest(guestHsUrl, guestIsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fall back to login screen
|
// fall back to login screen
|
||||||
|
|||||||
@@ -173,8 +173,8 @@ module.exports = React.createClass({
|
|||||||
Lifecycle.loadSession({
|
Lifecycle.loadSession({
|
||||||
queryParams: this.props.startingQueryParams,
|
queryParams: this.props.startingQueryParams,
|
||||||
enableGuest: this.props.enableGuest,
|
enableGuest: this.props.enableGuest,
|
||||||
hsUrl: this.getDefaultHsUrl(),
|
guestHsUrl: this.getCurrentHsUrl(),
|
||||||
isUrl: this.getDefaultIsUrl(),
|
guestIsUrl: this.getCurrentIsUrl(),
|
||||||
}).done(()=>{
|
}).done(()=>{
|
||||||
// stuff this through the dispatcher so that it happens
|
// stuff this through the dispatcher so that it happens
|
||||||
// after the on_logged_in action.
|
// after the on_logged_in action.
|
||||||
|
|||||||
Reference in New Issue
Block a user