feat: email verification
This commit is contained in:
		| @@ -1,6 +1,7 @@ | |||||||
| import React from 'react'; | import React from 'react'; | ||||||
| import withStyles from "@material-ui/core/styles/withStyles"; | import withStyles from "@material-ui/core/styles/withStyles"; | ||||||
| import {styles} from '../Register/registerStyle'; | import {styles} from '../Register/registerStyle'; | ||||||
|  | import {notification} from 'antd'; | ||||||
|  |  | ||||||
| import Grid from '@material-ui/core/Grid'; | import Grid from '@material-ui/core/Grid'; | ||||||
| import Paper from '@material-ui/core/Paper'; | import Paper from '@material-ui/core/Paper'; | ||||||
| @@ -43,6 +44,38 @@ class BTNLoginPage extends React.Component{ | |||||||
|         this.authStore = props.appstate.auth; |         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 => { |   handleChange = name => event => { | ||||||
|         this.setState({ |         this.setState({ | ||||||
|             [name]: event.target.value, |             [name]: event.target.value, | ||||||
|   | |||||||
| @@ -73,6 +73,13 @@ export class Authentication { | |||||||
|       }) |       }) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   @action | ||||||
|  |   verifyEmail(key) { | ||||||
|  |     return this.http.post('authentication/email_verification', { | ||||||
|  |       key | ||||||
|  |     }) | ||||||
|  |   } | ||||||
|  |  | ||||||
|   @action |   @action | ||||||
|   logout() { |   logout() { | ||||||
|     this.context.setToken(""); |     this.context.setToken(""); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user