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 | |
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')
-rw-r--r-- | src/components/auth/Login.js | 22 | ||||
-rw-r--r-- | src/components/auth/Signup.js | 22 | ||||
-rw-r--r-- | src/components/auth/Welcome.js | 21 |
3 files changed, 57 insertions, 8 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> |
diff --git a/src/components/auth/Signup.js b/src/components/auth/Signup.js index b36e71ce1..47e9daf18 100644 --- a/src/components/auth/Signup.js +++ b/src/components/auth/Signup.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, minLength } from '../../helpers/validation-helpers'; | 9 | import { required, email, minLength } 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'; |
@@ -58,18 +60,27 @@ const messages = defineMessages({ | |||
58 | id: 'signup.link.login', | 60 | id: 'signup.link.login', |
59 | defaultMessage: '!!!Already have an account, sign in?', | 61 | defaultMessage: '!!!Already have an account, sign in?', |
60 | }, | 62 | }, |
63 | changeServer: { | ||
64 | id: 'login.changeServer', | ||
65 | defaultMessage: '!!!Change server', | ||
66 | }, | ||
67 | serverless: { | ||
68 | id: 'services.serverless', | ||
69 | defaultMessage: '!!!Use Ferdi without an Account', | ||
70 | }, | ||
61 | emailDuplicate: { | 71 | emailDuplicate: { |
62 | id: 'signup.emailDuplicate', | 72 | id: 'signup.emailDuplicate', |
63 | defaultMessage: '!!!A user with that email address already exists', | 73 | defaultMessage: '!!!A user with that email address already exists', |
64 | }, | 74 | }, |
65 | }); | 75 | }); |
66 | 76 | ||
67 | export default @observer class Signup extends Component { | 77 | export default @observer @inject('actions') class Signup extends Component { |
68 | static propTypes = { | 78 | static propTypes = { |
69 | onSubmit: PropTypes.func.isRequired, | 79 | onSubmit: PropTypes.func.isRequired, |
70 | isSubmitting: PropTypes.bool.isRequired, | 80 | isSubmitting: PropTypes.bool.isRequired, |
71 | loginRoute: PropTypes.string.isRequired, | 81 | loginRoute: PropTypes.string.isRequired, |
72 | error: globalErrorPropType.isRequired, | 82 | error: globalErrorPropType.isRequired, |
83 | actions: PropTypes.object.isRequired, | ||
73 | }; | 84 | }; |
74 | 85 | ||
75 | static contextTypes = { | 86 | static contextTypes = { |
@@ -112,6 +123,10 @@ export default @observer class Signup extends Component { | |||
112 | }); | 123 | }); |
113 | } | 124 | } |
114 | 125 | ||
126 | useLocalServer() { | ||
127 | serverlessLogin(this.props.actions); | ||
128 | } | ||
129 | |||
115 | render() { | 130 | render() { |
116 | const { form } = this; | 131 | const { form } = this; |
117 | const { intl } = this.context; | 132 | const { intl } = this.context; |
@@ -183,7 +198,8 @@ export default @observer class Signup extends Component { | |||
183 | </p> | 198 | </p> |
184 | </form> | 199 | </form> |
185 | <div className="auth__links"> | 200 | <div className="auth__links"> |
186 | <Link to="/settings/app">Change server</Link> | 201 | <Link to="/settings/app">{intl.formatMessage(messages.changeServer)}</Link> |
202 | <a onClick={this.useLocalServer.bind(this)}>{intl.formatMessage(messages.serverless)}</a> | ||
187 | <Link to={loginRoute}>{intl.formatMessage(messages.loginLink)}</Link> | 203 | <Link to={loginRoute}>{intl.formatMessage(messages.loginLink)}</Link> |
188 | </div> | 204 | </div> |
189 | </div> | 205 | </div> |
diff --git a/src/components/auth/Welcome.js b/src/components/auth/Welcome.js index ef917e336..2ca8b430f 100644 --- a/src/components/auth/Welcome.js +++ b/src/components/auth/Welcome.js | |||
@@ -1,7 +1,9 @@ | |||
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, PropTypes as MobxPropTypes } from 'mobx-react'; | 4 | import { observer, PropTypes as MobxPropTypes, inject } from 'mobx-react'; |
4 | import { defineMessages, intlShape } from 'react-intl'; | 5 | import { defineMessages, intlShape } from 'react-intl'; |
6 | import serverlessLogin from '../../helpers/serverless-helpers'; | ||
5 | 7 | ||
6 | import Link from '../ui/Link'; | 8 | import Link from '../ui/Link'; |
7 | 9 | ||
@@ -14,19 +16,28 @@ const messages = defineMessages({ | |||
14 | id: 'welcome.loginButton', | 16 | id: 'welcome.loginButton', |
15 | defaultMessage: '!!!Login to your account', | 17 | defaultMessage: '!!!Login to your account', |
16 | }, | 18 | }, |
19 | serverless: { | ||
20 | id: 'services.serverless', | ||
21 | defaultMessage: '!!!Use Ferdi without an Account', | ||
22 | }, | ||
17 | }); | 23 | }); |
18 | 24 | ||
19 | export default @observer class Login extends Component { | 25 | export default @observer @inject('actions') class Login extends Component { |
20 | static propTypes = { | 26 | static propTypes = { |
21 | loginRoute: PropTypes.string.isRequired, | 27 | loginRoute: PropTypes.string.isRequired, |
22 | signupRoute: PropTypes.string.isRequired, | 28 | signupRoute: PropTypes.string.isRequired, |
23 | recipes: MobxPropTypes.arrayOrObservableArray.isRequired, | 29 | recipes: MobxPropTypes.arrayOrObservableArray.isRequired, |
30 | actions: PropTypes.object.isRequired, | ||
24 | }; | 31 | }; |
25 | 32 | ||
26 | static contextTypes = { | 33 | static contextTypes = { |
27 | intl: intlShape, | 34 | intl: intlShape, |
28 | }; | 35 | }; |
29 | 36 | ||
37 | useLocalServer() { | ||
38 | serverlessLogin(this.props.actions); | ||
39 | } | ||
40 | |||
30 | render() { | 41 | render() { |
31 | const { intl } = this.context; | 42 | const { intl } = this.context; |
32 | const { | 43 | const { |
@@ -53,6 +64,12 @@ export default @observer class Login extends Component { | |||
53 | </Link> | 64 | </Link> |
54 | <br /> | 65 | <br /> |
55 | <br /> | 66 | <br /> |
67 | <a className="button" onClick={this.useLocalServer.bind(this)}> | ||
68 | {intl.formatMessage(messages.serverless)} | ||
69 | </a> | ||
70 | <br /> | ||
71 | <br /> | ||
72 | |||
56 | 73 | ||
57 | <Link to="settings/app"> | 74 | <Link to="settings/app"> |
58 | <span style={{ | 75 | <span style={{ |