Fixed registration bugs: empty password gets registered, credentials not being sent

This commit is contained in:
VakarisZ 2020-06-15 11:33:56 +03:00
parent 39231abbab
commit 5996569607
3 changed files with 20 additions and 17 deletions

View File

@ -65,8 +65,8 @@ class RegisterPageComponent extends React.Component {
<h3 className='reg-subtitle'>Let's secure your island!</h3>
<div>
<Form className={'registration-form'}>
<Form.Control type='text' placeholder='Username'/>
<Form.Control type='password' placeholder='Password'/>
<Form.Control onChange={evt => this.updateUsername(evt)} type='text' placeholder='Username'/>
<Form.Control onChange={evt => this.updatePassword(evt)} type='password' placeholder='Password'/>
<Button id={'registration-button'} onClick={() => {
this.register()
}}>

View File

@ -1,5 +1,5 @@
import React, {Component} from 'react';
import {Col, Grid, Row} from 'react-bootstrap';
import {Col, Container, Row} from 'react-bootstrap';
import PillarsOverview from './PillarOverview';
import ZeroTrustReportLegend from './ReportLegend';
import * as PropTypes from 'prop-types';
@ -8,7 +8,7 @@ export default class SummarySection extends Component {
render() {
return <div id="summary-section">
<h2>Summary</h2>
<Grid fluid={true}>
<Container fluid>
<Row>
<Col xs={12} sm={12} md={12} lg={12}>
<p>
@ -28,7 +28,7 @@ export default class SummarySection extends Component {
<ZeroTrustReportLegend/>
</Col>
</Row>
</Grid>
</Container>
</div>
}
}

View File

@ -51,7 +51,11 @@ export default class AuthService {
};
register = (username, password) => {
return this._register(username, this.hashSha3(password));
if (password !== '') {
return this._register(username, this.hashSha3(password));
} else {
return this._register(username, password);
}
};
_register = (username, password) => {
@ -62,14 +66,14 @@ export default class AuthService {
'password_hash': password
})
}).then(res => {
if (res.status === 200) {
return this._login(username, password)
} else {
return res.json().then(res_json => {
return {result: false, error: res_json['error']};
})
}
})
if (res.status === 200) {
return this._login(username, password)
} else {
return res.json().then(res_json => {
return {result: false, error: res_json['error']};
})
}
})
};
_authFetch = (url, options = {}) => {
@ -101,7 +105,7 @@ export default class AuthService {
needsRegistration = () => {
return fetch(this.REGISTRATION_API_ENDPOINT,
{method: 'GET'})
{method: 'GET'})
.then(response => response.json())
.then(res => {
return res['needs_registration']
@ -132,8 +136,7 @@ export default class AuthService {
_isTokenExpired(token) {
try {
return decode(token)['exp'] - this.SECONDS_BEFORE_JWT_EXPIRES < Date.now() / 1000;
}
catch (err) {
} catch (err) {
return false;
}
}