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
+
+

Activate your Account

+

We have sent you an email with a code that you need to enter below in order to activate your account.

+ + this.setState({ + activation: { + ...this.state.activation, + code: code, + } + })} + /> + +
+ { + this.state.activation.resended && + } + + Didn't receive the email? + +
+ + { + this.state.activation.error &&
+ {this.state.activation.error.response.data.error} +
+ } + + + Activate + +
+
+ } + return
-

- Sign in -

-

- To continue to {config.app.siteName} -

+
+

+ Sign in +

+

+ To continue to {config.app.siteName} +

+
-
- {this.state.error} -
+ { + this.state.error &&
+ {this.state.error} +
+ }
Forgot your password? diff --git a/packages/app/src/components/Login/index.less b/packages/app/src/components/Login/index.less index dc2a88a5..2a39c7c6 100755 --- a/packages/app/src/components/Login/index.less +++ b/packages/app/src/components/Login/index.less @@ -47,20 +47,18 @@ padding: 40px 0; + gap: 20px; + border-radius: 12px; .fields { display: flex; flex-direction: column; - margin-top: 20px; - .field { display: flex; flex-direction: column; - margin-bottom: 20px; - transition: all 150ms ease-in-out; &.hidden {