From 2fc67d1c9bc2038179771238a0cb5d58995e05c3 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 21 Dec 2018 11:35:00 +0100 Subject: BasicAuth first draft --- src/features/basicAuth/Component.js | 102 ++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/features/basicAuth/Component.js (limited to 'src/features/basicAuth/Component.js') diff --git a/src/features/basicAuth/Component.js b/src/features/basicAuth/Component.js new file mode 100644 index 000000000..13395fb40 --- /dev/null +++ b/src/features/basicAuth/Component.js @@ -0,0 +1,102 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import injectSheet from 'react-jss'; +import { observer } from 'mobx-react'; +import classnames from 'classnames'; + +import Modal from '../../components/ui/Modal'; +import Input from '../../components/ui/Input'; +import Button from '../../components/ui/Button'; + +import { + state, + resetState, + sendCredentials, + cancelLogin, +} from '.'; +import Form from './Form'; + +import styles from './styles'; + +export default @injectSheet(styles) @observer class BasicAuthModal extends Component { + static propTypes = { + classes: PropTypes.object.isRequired, + } + + submit(e) { + e.preventDefault(); + + const values = Form.values(); + console.log('form submit', values); + + sendCredentials(values.user, values.password); + resetState(); + } + + cancel() { + cancelLogin(); + this.close(); + } + + close() { + resetState(); + state.isModalVisible = false; + } + + render() { + const { + classes, + } = this.props; + + const { + isModalVisible, + authInfo, + } = state; + + if (!authInfo) { + return null; + } + + return ( + +

Sign in

+

+ http + {authInfo.port === 443 && 's'} + :// + {authInfo.host} +

+
+ + +
+
+
+
+ ); + } +} -- cgit v1.2.3-54-g00ecf