Merge pull request #3043 from matrix-org/travis/check-login-for-config
Accept JSX into the GenericErrorPage and expose local session vars
This commit is contained in:
commit
1c41629376
3 changed files with 11 additions and 6 deletions
|
@ -14,6 +14,6 @@
|
|||
width: 500px;
|
||||
height: 200px;
|
||||
border: 1px solid #f22;
|
||||
padding: 10px;
|
||||
padding: 10px 10px 20px;
|
||||
background-color: #fcc;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ export async function loadSession(opts) {
|
|||
* @returns {String} The persisted session's owner, if an owner exists. Null otherwise.
|
||||
*/
|
||||
export function getStoredSessionOwner() {
|
||||
const {hsUrl, userId, accessToken} = _getLocalStorageSessionVars();
|
||||
const {hsUrl, userId, accessToken} = getLocalStorageSessionVars();
|
||||
return hsUrl && userId && accessToken ? userId : null;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ export function getStoredSessionOwner() {
|
|||
* for a real user. If there is no stored session, return null.
|
||||
*/
|
||||
export function getStoredSessionIsGuest() {
|
||||
const sessVars = _getLocalStorageSessionVars();
|
||||
const sessVars = getLocalStorageSessionVars();
|
||||
return sessVars.hsUrl && sessVars.userId && sessVars.accessToken ? sessVars.isGuest : null;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,12 @@ function _registerAsGuest(hsUrl, isUrl, defaultDeviceDisplayName) {
|
|||
});
|
||||
}
|
||||
|
||||
function _getLocalStorageSessionVars() {
|
||||
/**
|
||||
* Retrieves information about the stored session in localstorage. The session
|
||||
* may not be valid, as it is not tested for consistency here.
|
||||
* @returns {Object} Information about the session - see implementation for variables.
|
||||
*/
|
||||
export function getLocalStorageSessionVars() {
|
||||
const hsUrl = localStorage.getItem("mx_hs_url");
|
||||
const isUrl = localStorage.getItem("mx_is_url") || 'https://matrix.org';
|
||||
const accessToken = localStorage.getItem("mx_access_token");
|
||||
|
@ -271,7 +276,7 @@ async function _restoreFromLocalStorage() {
|
|||
return false;
|
||||
}
|
||||
|
||||
const {hsUrl, isUrl, accessToken, userId, deviceId, isGuest} = _getLocalStorageSessionVars();
|
||||
const {hsUrl, isUrl, accessToken, userId, deviceId, isGuest} = getLocalStorageSessionVars();
|
||||
|
||||
if (accessToken && userId && hsUrl) {
|
||||
console.log(`Restoring session for ${userId}`);
|
||||
|
|
|
@ -20,7 +20,7 @@ import {_t} from "../../languageHandler";
|
|||
|
||||
export default class GenericErrorPage extends React.PureComponent {
|
||||
static propTypes = {
|
||||
message: PropTypes.string.isRequired,
|
||||
message: PropTypes.object.isRequired, // jsx to display
|
||||
};
|
||||
|
||||
render() {
|
||||
|
|
Loading…
Reference in a new issue