diff --git a/tdrive/frontend/src/app/features/auth/auth-service.ts b/tdrive/frontend/src/app/features/auth/auth-service.ts index 9115eb63..058dd461 100644 --- a/tdrive/frontend/src/app/features/auth/auth-service.ts +++ b/tdrive/frontend/src/app/features/auth/auth-service.ts @@ -21,15 +21,7 @@ import LocalStorage from '@features/global/framework/local-storage-service'; import Globals from '@features/global/services/globals-tdrive-app-service'; type AccountType = 'remote' | 'internal'; -export type LoginState = - | '' - | 'app' - | 'error' - | 'signin' - | 'verify_mail' - | 'forgot_password' - | 'logged_out' - | 'logout'; +export type LoginState = '' | 'app' | 'error' | 'signin' | 'logged_out' | 'logout'; type InitState = '' | 'initializing' | 'initialized'; @TdriveService('AuthService') diff --git a/tdrive/frontend/src/app/views/login/internal/forgot-password/index.jsx b/tdrive/frontend/src/app/views/login/internal/forgot-password/index.jsx deleted file mode 100755 index bfb08b82..00000000 --- a/tdrive/frontend/src/app/views/login/internal/forgot-password/index.jsx +++ /dev/null @@ -1,332 +0,0 @@ -import React, { Component } from 'react'; - -import Languages from '@features/global/services/languages-service'; -import LoginService from '@features/auth/login-service'; -import AccountService from '@deprecated/login/account.js'; -import Emojione from 'components/emojione/emojione'; -import StepCounter from 'components/step-counter/step-counter.jsx'; -import ButtonWithTimeout from 'components/buttons/button-with-timeout.jsx'; -import Input from 'components/inputs/input.jsx'; -import { Typography } from 'antd'; - -export default class ForgotPassword extends Component { - constructor() { - super(); - - this.state = { - login: LoginService, - i18n: Languages, - email: '', - password1: '', - password2: '', - code: '', - page: 1, - - invalidForm: false, - patternRegMail: new RegExp( - "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", - ), - mailAvailable: true, - usernameAvailable: true, - errorPassword: false, - errorCode: false, - }; - LoginService.addListener(this); - Languages.addListener(this); - } - componentDidMount() { - if (this.input) { - this.input.focus(); - } - } - componentWillUnmount() { - LoginService.removeListener(this); - Languages.removeListener(this); - } - componentDidUpdate(_prevProps, prevState) { - if (prevState.page === this.state.page - 1 || prevState.page === this.state.page + 1) { - if (this.input) { - this.input.focus(); - } - if (this.inputcode) { - this.inputcode.focus(); - } - if (this.inputpassword) { - this.inputpassword.focus(); - } - } - } - displayStep() { - if (this.state.page === 1) { - return ( -
-
{this.state.i18n.t('scenes.login.forgot_password.text')}
- - { - this.input = ref; - }} - type="text" - className={ - 'bottom-margin full_width big ' + - (this.state.login.error_recover_nosuchmail ? 'error' : '') - } - onKeyDown={e => { - if (e.keyCode === 13 && this.checkForm() && !this.state.login.login_loading) { - this.next(); - } - }} - value={this.state.email} - id="email_to_recover" - placeholder={this.state.i18n.t('scenes.login.forgot_password.email_to_recover')} - onChange={evt => this.setState({ email: evt.target.value })} - /> - - {this.state.login.error_recover_nosuchmail && ( - - {this.state.i18n.t('scenes.login.forgot_password.mail_doesnt_exist')} - - )} - -
- this.previous()}> - {this.state.i18n.t('general.back')} - - this.next()} - value={this.state.i18n.t('general.continue')} - loading={this.state.login.login_loading} - loadingTimeout={2000} - /> -
-
- ); - } - if (this.state.page === 2) { - return ( -
-
- {this.state.i18n.t('scenes.login.forgot_password.text2')} -
- - { - this.inputcode = ref; - }} - id="code" - type="text" - onKeyDown={e => { - if ( - e.keyCode === 13 && - this.state.code.length > 0 && - this.checkForm() && - !this.state.login.login_loading - ) { - this.next(); - } - }} - placeholder={'123-456-789'} - value={this.state.code} - onChange={evt => this.setState({ code: evt.target.value })} - className={ - 'bottom-margin full_width big ' + - (this.state.login.error_recover_badcode ? 'error' : '') - } - style={{ textAlign: 'center' }} - /> -
- {this.state.login.error_recover_badcode && ( - - {this.state.i18n.t('scenes.login.forgot_password.invalid_code')} - - )} - -
- this.previous()}> - {this.state.i18n.t('general.back')} - - this.next()} - value={this.state.i18n.t('general.continue')} - loading={this.state.login.login_loading} - loadingTimeout={2000} - /> -
-
- ); - } - if (this.state.page === 3) { - this.checkForm(); - return ( -
-
{this.state.i18n.t('scenes.login.forgot_password.text3')}
- - { - this.inputpassword = ref; - }} - type="password" - onKeyDown={e => { - if (e.keyCode === 13 && this.checkForm() && !this.state.login.login_loading) { - this.next(); - } - }} - placeholder={this.state.i18n.t('scenes.login.forgot_password.password')} - value={this.state.password1} - onChange={evt => this.setState({ password1: evt.target.value })} - className={ - 'bottom-margin full_width medium ' + - ((this.state.errorPasswordDoesNotMatch || this.state.errorPassword) && - this.state.password1.length - ? 'error' - : '') - } - /> - - { - if (e.keyCode === 13 && this.checkForm() && !this.state.login.login_loading) { - this.next(); - } - }} - placeholder={this.state.i18n.t('scenes.login.forgot_password.password2')} - value={this.state.password2} - onChange={evt => this.setState({ password2: evt.target.value })} - className={ - 'bottom-margin full_width medium ' + - ((this.state.errorPasswordDoesNotMatch || this.state.errorPassword) && - this.state.password1.length - ? 'error' - : '') - } - /> - - {(this.state.login.error_recover_badpasswords || - this.state.login.error_recover_unknown || - this.state.errorPasswordDoesNotMatch || - this.state.errorPassword) && - this.state.password1.length > 0 && ( - - {this.state.i18n.t('scenes.login.forgot_password.password_dont_match')} - - )} - -
- this.previous()}> - {this.state.i18n.t('general.back')} - - this.next()} - value={this.state.i18n.t('general.continue')} - loading={this.state.login.login_loading} - loadingTimeout={2000} - /> -
-
- ); - } - if (this.state.page === 4) { - return ( -
-
- {this.state.i18n.t('scenes.login.forgot_password.finished')}{' '} - -
- -
- { - this.setState({ exiting: true }); - this.next(); - }} - value={this.state.i18n.t('general.continue')} - loading={this.state.login.login_loading} - loadingTimeout={2000} - /> -
-
- ); - } - } - checkForm() { - if (this.state.password1.length < 8) { - this.setState({ errorPassword: true }); - } else { - this.setState({ errorPassword: false }); - } - - if (this.state.password1 !== this.state.password2) { - this.setState({ errorPasswordDoesNotMatch: true }); - } else { - this.setState({ errorPasswordDoesNotMatch: false }); - } - - return ( - this.state.patternRegMail.test(this.state.email.toLocaleLowerCase()) && - this.state.email.length > 0 - ); - } - previous() { - if (this.state.page <= 1) { - this.state.login.changeState('logged_out'); - } else { - this.setState({ page: this.state.page - 1 }); - } - } - next() { - if (this.state.page === 1) { - if (this.checkForm()) { - AccountService.recover(this.state.email, () => { - this.setState({ page: this.state.page + 1 }); - }); - } - } else if (this.state.page === 2) { - if (this.checkForm()) { - AccountService.recoverCode(this.state.code, () => { - this.setState({ page: this.state.page + 1 }); - }); - } - } else if (this.state.page === 3) { - if (this.checkForm()) { - AccountService.recoverNewPassword(this.state.password1, this.state.password2, () => { - this.setState({ page: this.state.page + 1 }); - }); - } - } else if (this.state.page === 4) { - this.state.login.init(); - } else { - this.setState({ page: this.state.page + 1 }); - } - } - render() { - return ( -
-
-
- -
- {this.state.i18n.t('scenes.login.forgot_password.title')} {this.state.page}/4 -
- {this.displayStep()} -
-
-
- ); - } -} diff --git a/tdrive/frontend/src/app/views/login/internal/internal-login.tsx b/tdrive/frontend/src/app/views/login/internal/internal-login.tsx index 6ef02282..4b964e72 100755 --- a/tdrive/frontend/src/app/views/login/internal/internal-login.tsx +++ b/tdrive/frontend/src/app/views/login/internal/internal-login.tsx @@ -9,7 +9,6 @@ import Icon from '@components/icon/icon.jsx'; import LoginView from './login-view/login-view'; import Signin from './signin/signin.jsx'; -import ForgotPassword from './forgot-password/index.jsx'; import Error from './error'; import './login.scss'; @@ -44,7 +43,6 @@ export default () => { {LoginService.state === 'error' && } {LoginService.state === 'logged_out' && } {LoginService.state === 'signin' && } - {LoginService.state === 'forgot_password' && }
Tdrive {Globals.version.version_name}
diff --git a/tdrive/frontend/src/app/views/login/internal/login-view/login-view.jsx b/tdrive/frontend/src/app/views/login/internal/login-view/login-view.jsx index 53d353c5..4162a1c1 100755 --- a/tdrive/frontend/src/app/views/login/internal/login-view/login-view.jsx +++ b/tdrive/frontend/src/app/views/login/internal/login-view/login-view.jsx @@ -134,15 +134,6 @@ export default class LoginView extends Component { {this.state.i18n.t('scenes.login.home.create_account')} )} - {/* - this.state.login.changeState('forgot_password')} - id="forgot_password_btn" - className="blue_link" - > - {this.state.i18n.t('scenes.login.home.lost_password')} - - */}
)}