diff --git a/src/common/pages/Login/LoginBtn.js b/src/common/pages/Login/LoginBtn.js index 99a09eb..7e390fd 100644 --- a/src/common/pages/Login/LoginBtn.js +++ b/src/common/pages/Login/LoginBtn.js @@ -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,7 +44,39 @@ class BTNLoginPage extends React.Component{ this.authStore = props.appstate.auth; } - handleChange = name => event => { + 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, }); @@ -131,7 +164,7 @@ class BTNLoginPage extends React.Component{ { - this.state.isNeedEmailVerification && + this.state.isNeedEmailVerification && Your account still need email verification @@ -139,7 +172,7 @@ class BTNLoginPage extends React.Component{ Still not received any email? Resend email - +
} - +
@@ -205,4 +238,4 @@ class BTNLoginPage extends React.Component{ } } -export default withStyles(styles)(BTNLoginPage); \ No newline at end of file +export default withStyles(styles)(BTNLoginPage); diff --git a/src/common/stores/authenticaton.js b/src/common/stores/authenticaton.js index d4ba8d7..9b4f500 100644 --- a/src/common/stores/authenticaton.js +++ b/src/common/stores/authenticaton.js @@ -73,6 +73,13 @@ export class Authentication { }) } + @action + verifyEmail(key) { + return this.http.post('authentication/email_verification', { + key + }) + } + @action logout() { this.context.setToken("");