aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/LoginButton.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/components/LoginButton.js')
-rw-r--r--vnext/src/components/LoginButton.js16
1 files changed, 5 insertions, 11 deletions
diff --git a/vnext/src/components/LoginButton.js b/vnext/src/components/LoginButton.js
index fb3c087e..fbce6982 100644
--- a/vnext/src/components/LoginButton.js
+++ b/vnext/src/components/LoginButton.js
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
import Icon from './Icon';
import Modal from './Modal';
+import { auth } from '../api';
+
export default class LoginButton extends React.Component {
constructor(props) {
super(props);
@@ -30,18 +32,10 @@ export default class LoginButton extends React.Component {
}
login = (event) => {
event.preventDefault();
- let headers = new Headers();
- headers.append('Authorization', 'Basic ' + window.btoa(unescape(encodeURIComponent(this.state.username + ":" + this.state.password))));
- fetch('https://api.juick.com/auth', {
- method: 'GET',
- credentials: 'omit',
- headers: headers
- }).then(response => {
- return response.text()
- })
- .then(data => {
+ auth(this.state.username, this.state.password)
+ .then(response => {
this.toggleModal();
- this.props.onAuth(data);
+ this.props.onAuth(response);
}
).catch(ex => {
console.log(ex);