Finish forgot password and start test

This commit is contained in:
britea 2020-03-07 10:54:42 +01:00
parent f868041c2a
commit 0c443a7314
5 changed files with 71 additions and 7 deletions

21
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,21 @@
image: node:latest
stages:
- build
- test
cache:
paths:
- node_modules/
install_dependencies:
stage: build
script:
- npm install
artifacts:
paths:
- node_modules/
testing_testing:
stage: test
script: npm test

View file

@ -89,8 +89,8 @@ class App extends React.Component {
<Route path="/forgot-password" >
<ForgotPass />
</Route>
<Route path="/forgot-pass-change" >
<ChangePass />
<Route path="/forgot-pass-reset" >
<ChangePass query={this.state.query}/>
</Route>
</Switch>
);

View file

@ -8,7 +8,7 @@ export var call = {
.then(res => {
return res;
}).catch(err => {
return err;
return {status : "Errore"};
});
},
register: function(data, headers) {
@ -17,7 +17,23 @@ export var call = {
return res;
}).catch(err => {
//console.error(err);
return err;
return {status : "Errore"};
});
},
initResetPassword: function(data, headers) {
return axios.post(config + 'register/init-reset-password', data)
.then(res => {
return res;
}).catch(err => {
return {status : "Errore"};
});
},
resetPassword: function(data, headers) {
return axios.put(config + 'register/reset-password', data)
.then(res => {
return res;
}).catch(err => {
return {status : "Errore"};
});
},
};

View file

@ -1,6 +1,6 @@
import React, {Component} from 'react';
import {Button, Form, Grid, Header, Image, Icon, Message} from 'semantic-ui-react';
//import { call } from '../client_server';
import { call } from '../client_server';
export default class ChangePass extends Component {
@ -31,7 +31,20 @@ export default class ChangePass extends Component {
};
handleChangePassword = (e) => {
const params = {
"confirmationToken" : this.props.query.confirmationToken ,
"password" : this.state.password
}
call.resetPassword(params)
.then(res => {
if (res.status === "Errore") {
this.setState({ error: { state: true,
message: "Errore"}});
}
// else set a message that an email has been sent
}).catch(err => {
console.log(err);
});
};
render() {

View file

@ -1,6 +1,6 @@
import React, {Component} from 'react';
import {Button, Form, Grid, Header, Image, Icon, Message} from 'semantic-ui-react';
//import { call } from '../client_server';
import { call } from '../client_server';
export default class ForgotPass extends Component {
@ -22,7 +22,21 @@ export default class ForgotPass extends Component {
};
handleSendEmail = (e) => {
e.preventDefault();
const params = {
"email" : this.state.user,
}
call.initResetPassword(params)
.then(res => {
if (res.status === "Errore") {
this.setState({ error: { state: true,
message: "Errore"}});
}
//set a message that an email has been sent
}).catch(err => {
console.log(err);
});
};
render() {