2020-01-16 00:13:56 +03:00
|
|
|
/*
|
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { _t } from '../../../languageHandler';
|
2020-01-16 01:11:22 +03:00
|
|
|
import * as sdk from '../../../index';
|
2020-03-24 17:57:04 +03:00
|
|
|
import {
|
|
|
|
SetupEncryptionStore,
|
2021-03-09 02:28:44 +03:00
|
|
|
PHASE_LOADING,
|
2020-03-24 17:57:04 +03:00
|
|
|
PHASE_INTRO,
|
|
|
|
PHASE_BUSY,
|
|
|
|
PHASE_DONE,
|
|
|
|
PHASE_CONFIRM_SKIP,
|
|
|
|
} from '../../../stores/SetupEncryptionStore';
|
|
|
|
import SetupEncryptionBody from "./SetupEncryptionBody";
|
2021-03-09 05:35:10 +03:00
|
|
|
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
2020-01-16 00:13:56 +03:00
|
|
|
|
2021-03-09 05:35:10 +03:00
|
|
|
@replaceableComponent("structures.auth.CompleteSecurity")
|
2020-01-16 00:13:56 +03:00
|
|
|
export default class CompleteSecurity extends React.Component {
|
|
|
|
static propTypes = {
|
|
|
|
onFinished: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
2020-03-24 17:57:04 +03:00
|
|
|
const store = SetupEncryptionStore.sharedInstance();
|
|
|
|
store.on("update", this._onStoreUpdate);
|
|
|
|
store.start();
|
|
|
|
this.state = {phase: store.phase};
|
2020-01-25 23:42:45 +03:00
|
|
|
}
|
|
|
|
|
2020-03-24 17:57:04 +03:00
|
|
|
_onStoreUpdate = () => {
|
|
|
|
const store = SetupEncryptionStore.sharedInstance();
|
|
|
|
this.setState({phase: store.phase});
|
|
|
|
};
|
2020-01-16 00:13:56 +03:00
|
|
|
|
2020-03-24 17:57:04 +03:00
|
|
|
componentWillUnmount() {
|
|
|
|
const store = SetupEncryptionStore.sharedInstance();
|
|
|
|
store.off("update", this._onStoreUpdate);
|
|
|
|
store.stop();
|
2020-01-16 00:13:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const AuthPage = sdk.getComponent("auth.AuthPage");
|
2020-01-28 01:27:11 +03:00
|
|
|
const CompleteSecurityBody = sdk.getComponent("auth.CompleteSecurityBody");
|
2020-03-24 17:57:04 +03:00
|
|
|
const {phase} = this.state;
|
2020-01-16 00:13:56 +03:00
|
|
|
let icon;
|
|
|
|
let title;
|
2020-03-16 20:47:56 +03:00
|
|
|
|
2021-03-09 02:28:44 +03:00
|
|
|
if (phase === PHASE_LOADING) {
|
|
|
|
return null;
|
|
|
|
} else if (phase === PHASE_INTRO) {
|
2020-04-16 15:23:01 +03:00
|
|
|
icon = <span className="mx_CompleteSecurity_headerIcon mx_E2EIcon_warning" />;
|
2020-04-23 00:32:02 +03:00
|
|
|
title = _t("Verify this login");
|
2020-01-16 00:13:56 +03:00
|
|
|
} else if (phase === PHASE_DONE) {
|
2020-04-16 15:23:01 +03:00
|
|
|
icon = <span className="mx_CompleteSecurity_headerIcon mx_E2EIcon_verified" />;
|
2020-01-16 00:13:56 +03:00
|
|
|
title = _t("Session verified");
|
|
|
|
} else if (phase === PHASE_CONFIRM_SKIP) {
|
2020-04-16 15:23:01 +03:00
|
|
|
icon = <span className="mx_CompleteSecurity_headerIcon mx_E2EIcon_warning" />;
|
2020-01-16 00:13:56 +03:00
|
|
|
title = _t("Are you sure?");
|
2020-01-29 01:46:21 +03:00
|
|
|
} else if (phase === PHASE_BUSY) {
|
2020-04-16 15:23:01 +03:00
|
|
|
icon = <span className="mx_CompleteSecurity_headerIcon mx_E2EIcon_warning" />;
|
2020-04-23 00:32:02 +03:00
|
|
|
title = _t("Verify this login");
|
2020-01-16 00:13:56 +03:00
|
|
|
} else {
|
|
|
|
throw new Error(`Unknown phase ${phase}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<AuthPage>
|
2020-01-28 01:27:11 +03:00
|
|
|
<CompleteSecurityBody>
|
2020-01-16 00:13:56 +03:00
|
|
|
<h2 className="mx_CompleteSecurity_header">
|
|
|
|
{icon}
|
|
|
|
{title}
|
|
|
|
</h2>
|
|
|
|
<div className="mx_CompleteSecurity_body">
|
2020-03-24 17:57:04 +03:00
|
|
|
<SetupEncryptionBody onFinished={this.props.onFinished} />
|
2020-01-16 00:13:56 +03:00
|
|
|
</div>
|
2020-01-28 01:27:11 +03:00
|
|
|
</CompleteSecurityBody>
|
2020-01-16 00:13:56 +03:00
|
|
|
</AuthPage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|