diff options
author | 2019-10-14 10:38:27 +0200 | |
---|---|---|
committer | 2019-10-14 10:38:27 +0200 | |
commit | c84edee908d40a9cab45b9ae3c5dc899fbb3eb11 (patch) | |
tree | 80158d14869b59723d09535558358d62b2612c2b /src/components/auth/Login.js | |
parent | Add indicator for hibernating services (diff) | |
download | ferdium-app-c84edee908d40a9cab45b9ae3c5dc899fbb3eb11.tar.gz ferdium-app-c84edee908d40a9cab45b9ae3c5dc899fbb3eb11.tar.zst ferdium-app-c84edee908d40a9cab45b9ae3c5dc899fbb3eb11.zip |
Add local server to allow serverlesss usage
Diffstat (limited to 'src/components/auth/Login.js')
-rw-r--r-- | src/components/auth/Login.js | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/components/auth/Login.js b/src/components/auth/Login.js index eea5a09bf..e58016e25 100644 --- a/src/components/auth/Login.js +++ b/src/components/auth/Login.js | |||
@@ -1,11 +1,13 @@ | |||
1 | /* eslint jsx-a11y/anchor-is-valid: 0 */ | ||
1 | import React, { Component } from 'react'; | 2 | import React, { Component } from 'react'; |
2 | import PropTypes from 'prop-types'; | 3 | import PropTypes from 'prop-types'; |
3 | import { observer } from 'mobx-react'; | 4 | import { observer, inject } from 'mobx-react'; |
4 | import { defineMessages, intlShape } from 'react-intl'; | 5 | import { defineMessages, intlShape } from 'react-intl'; |
5 | 6 | ||
6 | import { isDevMode, useLiveAPI } from '../../environment'; | 7 | import { isDevMode, useLiveAPI } from '../../environment'; |
7 | import Form from '../../lib/Form'; | 8 | import Form from '../../lib/Form'; |
8 | import { required, email } from '../../helpers/validation-helpers'; | 9 | import { required, email } from '../../helpers/validation-helpers'; |
10 | import serverlessLogin from '../../helpers/serverless-helpers'; | ||
9 | import Input from '../ui/Input'; | 11 | import Input from '../ui/Input'; |
10 | import Button from '../ui/Button'; | 12 | import Button from '../ui/Button'; |
11 | import Link from '../ui/Link'; | 13 | import Link from '../ui/Link'; |
@@ -54,13 +56,21 @@ const messages = defineMessages({ | |||
54 | id: 'login.link.signup', | 56 | id: 'login.link.signup', |
55 | defaultMessage: '!!!Create a free account', | 57 | defaultMessage: '!!!Create a free account', |
56 | }, | 58 | }, |
59 | changeServer: { | ||
60 | id: 'login.changeServer', | ||
61 | defaultMessage: '!!!Change server', | ||
62 | }, | ||
63 | serverless: { | ||
64 | id: 'services.serverless', | ||
65 | defaultMessage: '!!!Use Ferdi without an Account', | ||
66 | }, | ||
57 | passwordLink: { | 67 | passwordLink: { |
58 | id: 'login.link.password', | 68 | id: 'login.link.password', |
59 | defaultMessage: '!!!Forgot password', | 69 | defaultMessage: '!!!Forgot password', |
60 | }, | 70 | }, |
61 | }); | 71 | }); |
62 | 72 | ||
63 | export default @observer class Login extends Component { | 73 | export default @observer @inject('actions') class Login extends Component { |
64 | static propTypes = { | 74 | static propTypes = { |
65 | onSubmit: PropTypes.func.isRequired, | 75 | onSubmit: PropTypes.func.isRequired, |
66 | isSubmitting: PropTypes.bool.isRequired, | 76 | isSubmitting: PropTypes.bool.isRequired, |
@@ -69,6 +79,7 @@ export default @observer class Login extends Component { | |||
69 | signupRoute: PropTypes.string.isRequired, | 79 | signupRoute: PropTypes.string.isRequired, |
70 | passwordRoute: PropTypes.string.isRequired, | 80 | passwordRoute: PropTypes.string.isRequired, |
71 | error: globalErrorPropType.isRequired, | 81 | error: globalErrorPropType.isRequired, |
82 | actions: PropTypes.object.isRequired, | ||
72 | }; | 83 | }; |
73 | 84 | ||
74 | static contextTypes = { | 85 | static contextTypes = { |
@@ -103,6 +114,10 @@ export default @observer class Login extends Component { | |||
103 | }); | 114 | }); |
104 | } | 115 | } |
105 | 116 | ||
117 | useLocalServer() { | ||
118 | serverlessLogin(this.props.actions); | ||
119 | } | ||
120 | |||
106 | render() { | 121 | render() { |
107 | const { form } = this; | 122 | const { form } = this; |
108 | const { intl } = this.context; | 123 | const { intl } = this.context; |
@@ -179,7 +194,8 @@ export default @observer class Login extends Component { | |||
179 | )} | 194 | )} |
180 | </form> | 195 | </form> |
181 | <div className="auth__links"> | 196 | <div className="auth__links"> |
182 | <Link to="/settings/app">Change server</Link> | 197 | <Link to="/settings/app">{intl.formatMessage(messages.changeServer)}</Link> |
198 | <a onClick={this.useLocalServer.bind(this)}>{intl.formatMessage(messages.serverless)}</a> | ||
183 | <Link to={signupRoute}>{intl.formatMessage(messages.signupLink)}</Link> | 199 | <Link to={signupRoute}>{intl.formatMessage(messages.signupLink)}</Link> |
184 | <Link to={passwordRoute}>{intl.formatMessage(messages.passwordLink)}</Link> | 200 | <Link to={passwordRoute}>{intl.formatMessage(messages.passwordLink)}</Link> |
185 | </div> | 201 | </div> |