added implementatio to retrieve URL query

This commit is contained in:
britea 2020-03-05 18:08:17 +01:00
parent dab9719311
commit a3e8555e49
3 changed files with 11 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import Signup from "./views/Signup";
import Login from "./views/Login"; import Login from "./views/Login";
import ForgotPass from "./views/Forgot-password"; import ForgotPass from "./views/Forgot-password";
import ChangePass from "./views/Forgot-pass-reset"; import ChangePass from "./views/Forgot-pass-reset";
import queryString from 'query-string';
import { call } from './client_server'; import { call } from './client_server';
@ -31,6 +32,13 @@ class App extends React.Component {
this.logout = this.logout.bind(this); this.logout = this.logout.bind(this);
} }
componentDidMount() {
const values = queryString.parse(this.props.location.search);
this.setState({
query : values
});
}
auth(data) { auth(data) {
return call.login(data.params) return call.login(data.params)
.then(res => { .then(res => {
@ -72,7 +80,7 @@ class App extends React.Component {
<Switch> <Switch>
<Route path="/" exact component={Home} /> <Route path="/" exact component={Home} />
<Route path="/login" > <Route path="/login" >
{this.state.loggedIn ? <Redirect to="/dashboard" /> : <Login auth={this.auth} />} { this.state.loggedIn ? <Redirect to="/dashboard" /> : <Login auth={this.auth} /> }
</Route> </Route>
<Route path="/signup" exact component={Signup} /> <Route path="/signup" exact component={Signup} />
<Route path="/dashboard" > <Route path="/dashboard" >

View file

@ -17,7 +17,7 @@ export var call = {
return res; return res;
}).catch(err => { }).catch(err => {
//console.error(err); //console.error(err);
return {status : "Errore"}; return err;
}); });
}, },
}; };

View file

@ -1,6 +1,7 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import {Button, Form, Grid, Header, Image, Message, Icon, Checkbox, Input} from 'semantic-ui-react'; import {Button, Form, Grid, Header, Image, Message, Icon, Checkbox, Input} from 'semantic-ui-react';
export default class Login extends Component { export default class Login extends Component {
constructor(props) { constructor(props) {
super(props); super(props);