diff options
Diffstat (limited to 'src/components/auth/Login.js')
-rw-r--r-- | src/components/auth/Login.js | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/src/components/auth/Login.js b/src/components/auth/Login.js index 956205258..bd01f25cd 100644 --- a/src/components/auth/Login.js +++ b/src/components/auth/Login.js | |||
@@ -5,14 +5,12 @@ import { observer, inject } from 'mobx-react'; | |||
5 | import { defineMessages, injectIntl } from 'react-intl'; | 5 | import { defineMessages, injectIntl } from 'react-intl'; |
6 | 6 | ||
7 | import { LIVE_FRANZ_API } from '../../config'; | 7 | import { LIVE_FRANZ_API } from '../../config'; |
8 | import { API_VERSION, isDevMode, useLiveAPI } from '../../environment-remote'; | 8 | import { API_VERSION } from '../../environment-remote'; |
9 | import Form from '../../lib/Form'; | 9 | import Form from '../../lib/Form'; |
10 | import { required, email } from '../../helpers/validation-helpers'; | 10 | import { required, email } from '../../helpers/validation-helpers'; |
11 | import serverlessLogin from '../../helpers/serverless-helpers'; | ||
12 | import Input from '../ui/Input'; | 11 | import Input from '../ui/Input'; |
13 | import Button from '../ui/Button'; | 12 | import Button from '../ui/Button'; |
14 | import Link from '../ui/Link'; | 13 | import Link from '../ui/Link'; |
15 | import Infobox from '../ui/Infobox'; | ||
16 | 14 | ||
17 | import { globalError as globalErrorPropType } from '../../prop-types'; | 15 | import { globalError as globalErrorPropType } from '../../prop-types'; |
18 | 16 | ||
@@ -57,22 +55,12 @@ const messages = defineMessages({ | |||
57 | id: 'login.link.signup', | 55 | id: 'login.link.signup', |
58 | defaultMessage: 'Create a free account', | 56 | defaultMessage: 'Create a free account', |
59 | }, | 57 | }, |
60 | changeServer: { | ||
61 | id: 'login.changeServer', | ||
62 | defaultMessage: 'Change server', | ||
63 | }, | ||
64 | serverless: { | ||
65 | id: 'services.serverless', | ||
66 | defaultMessage: 'Use Ferdi without an Account', | ||
67 | }, | ||
68 | passwordLink: { | 58 | passwordLink: { |
69 | id: 'login.link.password', | 59 | id: 'login.link.password', |
70 | defaultMessage: 'Reset password', | 60 | defaultMessage: 'Reset password', |
71 | }, | 61 | }, |
72 | }); | 62 | }); |
73 | 63 | ||
74 | @inject('actions') | ||
75 | @observer | ||
76 | class Login extends Component { | 64 | class Login extends Component { |
77 | static propTypes = { | 65 | static propTypes = { |
78 | onSubmit: PropTypes.func.isRequired, | 66 | onSubmit: PropTypes.func.isRequired, |
@@ -81,9 +69,7 @@ class Login extends Component { | |||
81 | isServerLogout: PropTypes.bool.isRequired, | 69 | isServerLogout: PropTypes.bool.isRequired, |
82 | signupRoute: PropTypes.string.isRequired, | 70 | signupRoute: PropTypes.string.isRequired, |
83 | passwordRoute: PropTypes.string.isRequired, | 71 | passwordRoute: PropTypes.string.isRequired, |
84 | changeServerRoute: PropTypes.string.isRequired, | ||
85 | error: globalErrorPropType.isRequired, | 72 | error: globalErrorPropType.isRequired, |
86 | actions: PropTypes.object.isRequired, | ||
87 | }; | 73 | }; |
88 | 74 | ||
89 | form = new Form( | 75 | form = new Form( |
@@ -105,8 +91,6 @@ class Login extends Component { | |||
105 | this.props.intl, | 91 | this.props.intl, |
106 | ); | 92 | ); |
107 | 93 | ||
108 | emailField = null; | ||
109 | |||
110 | submit(e) { | 94 | submit(e) { |
111 | e.preventDefault(); | 95 | e.preventDefault(); |
112 | this.form.submit({ | 96 | this.form.submit({ |
@@ -117,10 +101,6 @@ class Login extends Component { | |||
117 | }); | 101 | }); |
118 | } | 102 | } |
119 | 103 | ||
120 | useLocalServer() { | ||
121 | serverlessLogin(this.props.actions); | ||
122 | } | ||
123 | |||
124 | render() { | 104 | render() { |
125 | const { form } = this; | 105 | const { form } = this; |
126 | const { intl } = this.props; | 106 | const { intl } = this.props; |
@@ -130,21 +110,14 @@ class Login extends Component { | |||
130 | isServerLogout, | 110 | isServerLogout, |
131 | signupRoute, | 111 | signupRoute, |
132 | passwordRoute, | 112 | passwordRoute, |
133 | changeServerRoute, | ||
134 | error, | 113 | error, |
135 | } = this.props; | 114 | } = this.props; |
136 | 115 | ||
137 | return ( | 116 | return ( |
138 | <div className="auth__container"> | 117 | <div className="auth__container"> |
139 | <form className="franz-form auth__form" onSubmit={e => this.submit(e)}> | 118 | <form className="franz-form auth__form" onSubmit={e => this.submit(e)}> |
140 | <img src="./assets/images/logo.svg" className="auth__logo" alt="" /> | 119 | <Link to='/auth/welcome'><img src="./assets/images/logo.svg" className="auth__logo" alt="" /></Link> |
141 | <h1>{intl.formatMessage(messages.headline)}</h1> | 120 | <h1>{intl.formatMessage(messages.headline)}</h1> |
142 | {isDevMode && !useLiveAPI && ( | ||
143 | <Infobox type="warning"> | ||
144 | In Dev Mode your data is not persistent. Please use the live app | ||
145 | for accessing the production API. | ||
146 | </Infobox> | ||
147 | )} | ||
148 | {isTokenExpired && ( | 121 | {isTokenExpired && ( |
149 | <p className="error-message center"> | 122 | <p className="error-message center"> |
150 | {intl.formatMessage(messages.tokenExpired)} | 123 | {intl.formatMessage(messages.tokenExpired)} |
@@ -155,13 +128,7 @@ class Login extends Component { | |||
155 | {intl.formatMessage(messages.serverLogout)} | 128 | {intl.formatMessage(messages.serverLogout)} |
156 | </p> | 129 | </p> |
157 | )} | 130 | )} |
158 | <Input | 131 | <Input field={form.$('email')} focus /> |
159 | field={form.$('email')} | ||
160 | ref={element => { | ||
161 | this.emailField = element; | ||
162 | }} | ||
163 | focus | ||
164 | /> | ||
165 | <Input field={form.$('password')} showPasswordToggle /> | 132 | <Input field={form.$('password')} showPasswordToggle /> |
166 | {error.code === 'invalid-credentials' && ( | 133 | {error.code === 'invalid-credentials' && ( |
167 | <> | 134 | <> |
@@ -205,12 +172,6 @@ class Login extends Component { | |||
205 | )} | 172 | )} |
206 | </form> | 173 | </form> |
207 | <div className="auth__links"> | 174 | <div className="auth__links"> |
208 | <Link to={changeServerRoute}> | ||
209 | {intl.formatMessage(messages.changeServer)} | ||
210 | </Link> | ||
211 | <a onClick={this.useLocalServer.bind(this)}> | ||
212 | {intl.formatMessage(messages.serverless)} | ||
213 | </a> | ||
214 | <Link to={signupRoute}> | 175 | <Link to={signupRoute}> |
215 | {intl.formatMessage(messages.signupLink)} | 176 | {intl.formatMessage(messages.signupLink)} |
216 | </Link> | 177 | </Link> |
@@ -223,4 +184,4 @@ class Login extends Component { | |||
223 | } | 184 | } |
224 | } | 185 | } |
225 | 186 | ||
226 | export default injectIntl(Login); | 187 | export default injectIntl(inject('actions')(observer(Login))); |