mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-28 19:35:15 +00:00
Fix errors
This commit is contained in:
parent
50154a009c
commit
fc1d6fc567
@ -145,7 +145,7 @@ func limitMiddleware(next http.HandlerFunc, limiter *IPRateLimiter) http.Handler
|
|||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
limiter := limiter.GetLimiter(r.RemoteAddr)
|
limiter := limiter.GetLimiter(r.RemoteAddr)
|
||||||
if !limiter.Allow() {
|
if !limiter.Allow() {
|
||||||
msg := generateJsonError("Too many requests")
|
msg := generateJsonMessage("Too many requests")
|
||||||
w.WriteHeader(http.StatusTooManyRequests)
|
w.WriteHeader(http.StatusTooManyRequests)
|
||||||
w.Write(msg)
|
w.Write(msg)
|
||||||
return
|
return
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.toastNotifs {
|
||||||
|
margin-top: 100px;
|
||||||
|
z-index: 99999!important;
|
||||||
|
}
|
||||||
|
|
||||||
.App-header {
|
.App-header {
|
||||||
background-color: #282c34;
|
background-color: #282c34;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
|
@ -29,8 +29,7 @@ const App = () => {
|
|||||||
let exact = true
|
let exact = true
|
||||||
return (
|
return (
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
<ToastProvider autoDismiss="true" autoDismissTimeout="5000">
|
<ToastProvider autoDismiss="true" autoDismissTimeout="5000" placement="bottom-right">
|
||||||
<div className="wrapper">
|
|
||||||
<Navigation />
|
<Navigation />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact={exact} path="/" component={Home} />
|
<Route exact={exact} path="/" component={Home} />
|
||||||
@ -38,7 +37,6 @@ const App = () => {
|
|||||||
<Route path="/login" component={Login} />
|
<Route path="/login" component={Login} />
|
||||||
<Route path="/register" component={Register} />
|
<Route path="/register" component={Register} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
|
||||||
</ToastProvider>
|
</ToastProvider>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
);
|
);
|
||||||
|
@ -5,23 +5,6 @@ import { Button } from 'reactstrap';
|
|||||||
|
|
||||||
import { useToasts } from 'react-toast-notifications';
|
import { useToasts } from 'react-toast-notifications';
|
||||||
|
|
||||||
// const FormWithToasts = () => {
|
|
||||||
// const { addToast } = useToasts();
|
|
||||||
|
|
||||||
// const onSubmit = async value => {
|
|
||||||
// // const { error } = await dataPersistenceLayer(value);
|
|
||||||
|
|
||||||
// if (error) {
|
|
||||||
// addToast(error.message, { appearance: 'error' });
|
|
||||||
// } else {
|
|
||||||
// addToast('Saved Successfully', { appearance: 'success' });
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// return <form onSubmit={this.handleSubmit}>...</form>;
|
|
||||||
// };
|
|
||||||
// const { addToast } = useToasts();
|
|
||||||
|
|
||||||
function withToast(Component) {
|
function withToast(Component) {
|
||||||
return function WrappedComponent(props) {
|
return function WrappedComponent(props) {
|
||||||
const toastFuncs = useToasts()
|
const toastFuncs = useToasts()
|
||||||
@ -52,6 +35,7 @@ class Login extends React.Component {
|
|||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
timeout: 5000,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
username: this.state.username,
|
username: this.state.username,
|
||||||
password: this.state.password,
|
password: this.state.password,
|
||||||
@ -68,6 +52,10 @@ class Login extends React.Component {
|
|||||||
}
|
}
|
||||||
this.setState({loading: false});
|
this.setState({loading: false});
|
||||||
}).bind(this))
|
}).bind(this))
|
||||||
|
.catch(() => {
|
||||||
|
this.props.addToast('Error submitting form. Please try again', { appearance: 'error' });
|
||||||
|
this.setState({loading: false});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -47,10 +47,10 @@ class Register extends React.Component {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.password.len < 8) {
|
// if (this.state.password.len < 8) {
|
||||||
this.props.addToast('Passwords do not match', { appearance: 'error' });
|
// this.props.addToast('Password must be at least 8 characters', { appearance: 'error' });
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.setState({loading: true});
|
this.setState({loading: true});
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
@ -67,6 +67,7 @@ class Register extends React.Component {
|
|||||||
fetch(apiUrl, requestOptions)
|
fetch(apiUrl, requestOptions)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((function(data) {
|
.then((function(data) {
|
||||||
|
console.log(data);
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
this.props.addToast(data.error, { appearance: 'error' });
|
this.props.addToast(data.error, { appearance: 'error' });
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user