Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1167 | not auto logging in user on email co…
Browse files Browse the repository at this point in the history
…nfirmation
  • Loading branch information
snyaggarwal committed Jan 5, 2022
1 parent 1a4cbf8 commit a551f05
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions src/components/users/EmailVerification.jsx
Expand Up @@ -5,7 +5,7 @@ import { Paper, Button, CircularProgress } from '@mui/material';
import MuiAlert from '@mui/material/Alert';
import { get } from 'lodash';
import APIService from '../../services/APIService';
import { refreshCurrentUserCache, getSiteTitle } from '../../common/utils';
import { getSiteTitle } from '../../common/utils';

const SITE_TITLE = getSiteTitle()

Expand Down Expand Up @@ -42,27 +42,15 @@ class EmailVerification extends React.Component {
const { username, token } = this.state
APIService.users(username).verify(token).get().then(response => {
if(get(response, 'status') === 200 && get(response, 'data.token')) {
window.location.hash = '#/accounts/login'
alertifyjs.success('Successfully Verified Email.')
this.afterLoginSuccess(response.data.token)
} else if(get(response, 'detail'))
this.setState({failureMsg: response.detail})
else
alertifyjs.error('Something bad happend')
})
}

afterLoginSuccess(token) {
localStorage.setItem('token', token)
this.cacheUserData()
}

cacheUserData() {
refreshCurrentUserCache(response => {
alertifyjs.success(`Successfully signed in as ${this.state.username}.`)
window.location.hash = '#' + response.data.url
})
}

getNotFoundDOM() {
return (
<MuiAlert elevation={6} variant="filled" severity="error">
Expand Down Expand Up @@ -95,11 +83,9 @@ class EmailVerification extends React.Component {
const { user } = this.state;
return (
<React.Fragment>
<h1 style={{textAlign: 'center'}}>Confirm Email Address</h1>
<p>
{
`Please confirm that ${user.email} is an email address for user ${user.username}.`
}
<h1 style={{textAlign: 'center', margin: '10px 0'}}>Confirm Email Address</h1>
<p style={{marginTop: '5px'}}>
Please confirm that <b>{user.email}</b> is an email address for user <b>{user.username}</b>.
</p>
<Button onClick={() => this.onSubmit()} variant='outlined' color='primary'>
Confirm
Expand Down

0 comments on commit a551f05

Please sign in to comment.