feat: email verification

This commit is contained in:
Hasta Ragil Saputra 2019-01-29 15:12:06 +07:00
parent 327e01ef9e
commit 2f4c76d48a
2 changed files with 46 additions and 6 deletions

View File

@ -1,6 +1,7 @@
import React from 'react';
import withStyles from "@material-ui/core/styles/withStyles";
import {styles} from '../Register/registerStyle';
import {notification} from 'antd';
import Grid from '@material-ui/core/Grid';
import Paper from '@material-ui/core/Paper';
@ -43,6 +44,38 @@ class BTNLoginPage extends React.Component{
this.authStore = props.appstate.auth;
}
componentDidMount() {
const urlParams = new URLSearchParams(window.location.search);
if(urlParams.has('key')) {
this.setState({
isLoading: true
});
this.authStore.verifyEmail(urlParams.get('key')).then((res) => {
if(res.login_request_id) {
notification.open({
message: 'Email Verification',
description: 'Email verification success'
});
this.setState({
isLoading: false
});
//redirect to otp page
} else {
notification.open({
message: 'Email Verification',
description: res.message
});
this.setState({
isLoading: false
});
// res.message
}
})
}
}
handleChange = name => event => {
this.setState({
[name]: event.target.value,

View File

@ -73,6 +73,13 @@ export class Authentication {
})
}
@action
verifyEmail(key) {
return this.http.post('authentication/email_verification', {
key
})
}
@action
logout() {
this.context.setToken("");