From c84edee908d40a9cab45b9ae3c5dc899fbb3eb11 Mon Sep 17 00:00:00 2001
From: vantezzen
Date: Mon, 14 Oct 2019 10:38:27 +0200
Subject: Add local server to allow serverlesss usage
---
src/components/auth/Login.js | 22 +++++++++++++++++++---
src/components/auth/Signup.js | 22 +++++++++++++++++++---
src/components/auth/Welcome.js | 21 +++++++++++++++++++--
3 files changed, 57 insertions(+), 8 deletions(-)
(limited to 'src/components/auth')
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 @@
+/* eslint jsx-a11y/anchor-is-valid: 0 */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
-import { observer } from 'mobx-react';
+import { observer, inject } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
import { isDevMode, useLiveAPI } from '../../environment';
import Form from '../../lib/Form';
import { required, email } from '../../helpers/validation-helpers';
+import serverlessLogin from '../../helpers/serverless-helpers';
import Input from '../ui/Input';
import Button from '../ui/Button';
import Link from '../ui/Link';
@@ -54,13 +56,21 @@ const messages = defineMessages({
id: 'login.link.signup',
defaultMessage: '!!!Create a free account',
},
+ changeServer: {
+ id: 'login.changeServer',
+ defaultMessage: '!!!Change server',
+ },
+ serverless: {
+ id: 'services.serverless',
+ defaultMessage: '!!!Use Ferdi without an Account',
+ },
passwordLink: {
id: 'login.link.password',
defaultMessage: '!!!Forgot password',
},
});
-export default @observer class Login extends Component {
+export default @observer @inject('actions') class Login extends Component {
static propTypes = {
onSubmit: PropTypes.func.isRequired,
isSubmitting: PropTypes.bool.isRequired,
@@ -69,6 +79,7 @@ export default @observer class Login extends Component {
signupRoute: PropTypes.string.isRequired,
passwordRoute: PropTypes.string.isRequired,
error: globalErrorPropType.isRequired,
+ actions: PropTypes.object.isRequired,
};
static contextTypes = {
@@ -103,6 +114,10 @@ export default @observer class Login extends Component {
});
}
+ useLocalServer() {
+ serverlessLogin(this.props.actions);
+ }
+
render() {
const { form } = this;
const { intl } = this.context;
@@ -179,7 +194,8 @@ export default @observer class Login extends Component {
)}
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 @@
+/* eslint jsx-a11y/anchor-is-valid: 0 */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
-import { observer } from 'mobx-react';
+import { observer, inject } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
import { isDevMode, useLiveAPI } from '../../environment';
import Form from '../../lib/Form';
import { required, email, minLength } from '../../helpers/validation-helpers';
+import serverlessLogin from '../../helpers/serverless-helpers';
import Input from '../ui/Input';
import Button from '../ui/Button';
import Link from '../ui/Link';
@@ -58,18 +60,27 @@ const messages = defineMessages({
id: 'signup.link.login',
defaultMessage: '!!!Already have an account, sign in?',
},
+ changeServer: {
+ id: 'login.changeServer',
+ defaultMessage: '!!!Change server',
+ },
+ serverless: {
+ id: 'services.serverless',
+ defaultMessage: '!!!Use Ferdi without an Account',
+ },
emailDuplicate: {
id: 'signup.emailDuplicate',
defaultMessage: '!!!A user with that email address already exists',
},
});
-export default @observer class Signup extends Component {
+export default @observer @inject('actions') class Signup extends Component {
static propTypes = {
onSubmit: PropTypes.func.isRequired,
isSubmitting: PropTypes.bool.isRequired,
loginRoute: PropTypes.string.isRequired,
error: globalErrorPropType.isRequired,
+ actions: PropTypes.object.isRequired,
};
static contextTypes = {
@@ -112,6 +123,10 @@ export default @observer class Signup extends Component {
});
}
+ useLocalServer() {
+ serverlessLogin(this.props.actions);
+ }
+
render() {
const { form } = this;
const { intl } = this.context;
@@ -183,7 +198,8 @@ export default @observer class Signup extends Component {
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 @@
+/* eslint jsx-a11y/anchor-is-valid: 0 */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
-import { observer, PropTypes as MobxPropTypes } from 'mobx-react';
+import { observer, PropTypes as MobxPropTypes, inject } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
+import serverlessLogin from '../../helpers/serverless-helpers';
import Link from '../ui/Link';
@@ -14,19 +16,28 @@ const messages = defineMessages({
id: 'welcome.loginButton',
defaultMessage: '!!!Login to your account',
},
+ serverless: {
+ id: 'services.serverless',
+ defaultMessage: '!!!Use Ferdi without an Account',
+ },
});
-export default @observer class Login extends Component {
+export default @observer @inject('actions') class Login extends Component {
static propTypes = {
loginRoute: PropTypes.string.isRequired,
signupRoute: PropTypes.string.isRequired,
recipes: MobxPropTypes.arrayOrObservableArray.isRequired,
+ actions: PropTypes.object.isRequired,
};
static contextTypes = {
intl: intlShape,
};
+ useLocalServer() {
+ serverlessLogin(this.props.actions);
+ }
+
render() {
const { intl } = this.context;
const {
@@ -53,6 +64,12 @@ export default @observer class Login extends Component {
+
+ {intl.formatMessage(messages.serverless)}
+
+
+
+