diff --git a/packages/app/src/components/Login/index.jsx b/packages/app/src/components/Login/index.jsx index c0f6eb53..ea5950ae 100755 --- a/packages/app/src/components/Login/index.jsx +++ b/packages/app/src/components/Login/index.jsx @@ -40,7 +40,9 @@ class Login extends React.Component { loginInputs: {}, error: null, phase: 0, + mfa_required: null, + activation: null, forbidden: false, } @@ -67,6 +69,15 @@ class Login extends React.Component { forbidden: error.response.data.violation }) } + + if (error.response.data.activation_required) { + return this.setState({ + activation: { + required: true, + user_id: error.response.data.user_id, + }, + }) + } } console.error(error, error.response) @@ -95,12 +106,61 @@ class Login extends React.Component { } if (typeof this.props.onDone === "function") { - this.props.onDone() + await this.props.onDone() } return true } + onClickActivateAccount = async () => { + const activationObj = this.state.activation + + if (!activationObj) { + return null + } + + try { + await AuthModel.activateAccount( + this.state.activation.user_id, + this.state.activation.code + ) + + this.handleFinish() + } catch (error) { + this.setState({ + activation: { + ...this.state.activation, + error: error + } + }) + + console.error(error) + } + } + + onClickResendActivationCode = async () => { + const activationObj = this.state.activation + + if (!activationObj) { + return null + } + + const rensendObj = await AuthModel.resendActivationCode(activationObj.user_id) + .catch((error) => { + app.message.info(`Please try again later...`) + return null + }) + + if (rensendObj) { + this.setState({ + activation: { + ...this.state.activation, + resended: rensendObj.date, + }, + }) + } + } + onClickForgotPassword = () => { if (this.props.locked) { this.props.unlock() @@ -235,14 +295,61 @@ class Login extends React.Component { } + if (this.state.activation) { + return
We have sent you an email with a code that you need to enter below in order to activate your account.
+ +