mirror of
				https://github.com/vector-im/element-web.git
				synced 2025-11-04 10:11:03 +01:00 
			
		
		
		
	Support InteractiveAuth based registration
Passes in a function to make a register URL rather than just passing in the URL base
This commit is contained in:
		
							parent
							
								
									bb4d8ee3e8
								
							
						
					
					
						commit
						a8e99109b1
					
				@ -1,5 +1,6 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2015, 2016 OpenMarket Ltd
 | 
					Copyright 2015, 2016 OpenMarket Ltd
 | 
				
			||||||
 | 
					Copyright 2017 Vector Creations Ltd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@ -147,16 +148,30 @@ var onNewScreen = function(screen) {
 | 
				
			|||||||
// If we're in electron, we should never pass through a file:// URL otherwise
 | 
					// If we're in electron, we should never pass through a file:// URL otherwise
 | 
				
			||||||
// the identity server will try to 302 the browser to it, which breaks horribly.
 | 
					// the identity server will try to 302 the browser to it, which breaks horribly.
 | 
				
			||||||
// so in that instance, hardcode to use riot.im/app for now instead.
 | 
					// so in that instance, hardcode to use riot.im/app for now instead.
 | 
				
			||||||
var makeRegistrationUrl = function() {
 | 
					var makeRegistrationUrl = function(params) {
 | 
				
			||||||
 | 
					    let url;
 | 
				
			||||||
    if (window.location.protocol === "file:") {
 | 
					    if (window.location.protocol === "file:") {
 | 
				
			||||||
        return 'https://riot.im/app/#/register';
 | 
					        url = 'https://riot.im/app/#/register';
 | 
				
			||||||
    }
 | 
					    } else {
 | 
				
			||||||
    else {
 | 
					        url = (
 | 
				
			||||||
        return window.location.protocol + '//' +
 | 
					            window.location.protocol + '//' +
 | 
				
			||||||
            window.location.host +
 | 
					            window.location.host +
 | 
				
			||||||
            window.location.pathname +
 | 
					            window.location.pathname +
 | 
				
			||||||
               '#/register';
 | 
					            '#/register'
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const keys = Object.keys(params);
 | 
				
			||||||
 | 
					    for (let i = 0; i < keys.length; ++i) {
 | 
				
			||||||
 | 
					        if (i == 0) {
 | 
				
			||||||
 | 
					            url += '?';
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            url += '&';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        const k = keys[i];
 | 
				
			||||||
 | 
					        url += k + '=' + encodeURIComponent(params[k]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return url;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
window.addEventListener('hashchange', onHashChange);
 | 
					window.addEventListener('hashchange', onHashChange);
 | 
				
			||||||
@ -258,7 +273,7 @@ async function loadApp() {
 | 
				
			|||||||
        window.matrixChat = ReactDOM.render(
 | 
					        window.matrixChat = ReactDOM.render(
 | 
				
			||||||
            <MatrixChat
 | 
					            <MatrixChat
 | 
				
			||||||
                onNewScreen={onNewScreen}
 | 
					                onNewScreen={onNewScreen}
 | 
				
			||||||
                registrationUrl={makeRegistrationUrl()}
 | 
					                makeRegistrationUrl={makeRegistrationUrl}
 | 
				
			||||||
                ConferenceHandler={VectorConferenceHandler}
 | 
					                ConferenceHandler={VectorConferenceHandler}
 | 
				
			||||||
                config={configJson}
 | 
					                config={configJson}
 | 
				
			||||||
                realQueryParams={params}
 | 
					                realQueryParams={params}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user