1
0
Fork 0

basic login

This commit is contained in:
Amarpreet Minhas 2019-09-14 20:29:55 -04:00
parent 84e275bf45
commit aa6f98f91f
3 changed files with 26 additions and 6 deletions

View file

@ -17,3 +17,15 @@ export const fetchUserProfile = (user) => async (dispatch) => {
const response = { ...profile.data, ...test }
dispatch({ type: 'FETCH_USER', payload: response })
};
export const userLogin = (username, password) => async (dispatch) => {
const response = await sudoscientist.post('/auth/signin', {
username: username,
password: password
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
console.log(response)
};

View file

@ -1,5 +1,5 @@
import axios from 'axios';
export default axios.create({
baseURL: 'https://api.sudoscientist.com/v1/api/'
baseURL: 'http://localhost:8080/v1/api/'
});

View file

@ -1,10 +1,13 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { userLogin } from '../actions';
class AuthMenu extends Component {
constructor (props) {
super(props)
this.state = {
user_authed: false,
where_in_auth_menu: "requestUsername",
username: "",
password: "",
@ -58,10 +61,7 @@ class AuthMenu extends Component {
}
handleLogin() {
this.setState(state => ({
where_in_auth_menu: "requestPasswordForCreation",
auth_menu_visible: true,
}));
this.props.userLogin(this.state.username, this.state.password)
}
handleCreateAccount() {
@ -157,4 +157,12 @@ class AuthMenu extends Component {
}
}
export default (AuthMenu)
const mapStateToProps = (state) => {
return {
username: state.username,
};
}
export default connect(
mapStateToProps,
{ userLogin }
)(AuthMenu);