Merge branch '23-implement-url-query-retrieve' into 'dev'

Resolve "Implement URL query retrieve"

Closes #23

See merge request sa4-2020/the-sanmarinoes/frontend!14
This commit is contained in:
Matteo Omenetti 2020-03-05 18:18:28 +01:00
commit f868041c2a
4 changed files with 42 additions and 2 deletions

31
package-lock.json generated Normal file
View file

@ -0,0 +1,31 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"decode-uri-component": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
"integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU="
},
"query-string": {
"version": "6.11.1",
"resolved": "https://registry.npmjs.org/query-string/-/query-string-6.11.1.tgz",
"integrity": "sha512-1ZvJOUl8ifkkBxu2ByVM/8GijMIPx+cef7u3yroO3Ogm4DOdZcF5dcrWTIlSHe3Pg/mtlt6/eFjObDfJureZZA==",
"requires": {
"decode-uri-component": "^0.2.0",
"split-on-first": "^1.0.0",
"strict-uri-encode": "^2.0.0"
}
},
"split-on-first": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz",
"integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw=="
},
"strict-uri-encode": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",
"integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY="
}
}
}

View file

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

View file

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

View file

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