-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangePassword.js
More file actions
183 lines (149 loc) · 6.14 KB
/
ChangePassword.js
File metadata and controls
183 lines (149 loc) · 6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import React, {useEffect, useState} from 'react';
import Avatar from '@material-ui/core/Avatar';
import Button from '@material-ui/core/Button';
import CssBaseline from '@material-ui/core/CssBaseline';
import TextField from '@material-ui/core/TextField';
import Link from '@material-ui/core/Link';
import Grid from '@material-ui/core/Grid';
import Box from '@material-ui/core/Box';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
import Container from '@material-ui/core/Container';
import VpnKeyIcon from '@material-ui/icons/VpnKey';
import {useHistory} from "react-router-dom";
import axios from "axios";
function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<Link color="inherit" href="/#">
Recce Labs (PVT) Ltd
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
const useStyles = makeStyles((theme) => ({
paper: {
marginTop: theme.spacing(8),
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
},
avatar: {
margin: theme.spacing(1),
backgroundColor: theme.palette.secondary.main,
},
form: {
width: '100%', // Fix IE 11 issue.
marginTop: theme.spacing(3),
},
submit: {
margin: theme.spacing(3, 0, 2),
},
}));
export default function ChangePassword() {
const classes = useStyles();
const history = useHistory();
const [password,setPassword]=useState("")
useEffect(()=>{},[password])
const handleClick = (e) => {
// history.push("/sign-in")
e.preventDefault()
axios.post("/password-validate",{
password:password
})
.then(response => {
console.log(response)
if(response.data.password_responce==="401"){
console.log("Invalid Password")
window.location="/reset-password"
}
else {
console.log("valid Password")
localStorage.setItem('password',password)
console.log(window.localStorage.getItem('id'))
console.log(window.localStorage.getItem('password'))
axios.post("/change-password",{
id:window.localStorage.getItem('id'),
password:window.localStorage.getItem('password')
})
.then(response=>{
console.log(response)
console.log(response.data.result[0].msg)
if(response.data.result[0].msg==="success"){
window.localStorage.clear();
console.log("Sign-In Page")
history.push("/sign-in")
}
})
}
})
}
return (
<Container component="main" maxWidth="xs">
<CssBaseline />
<div className={classes.paper}>
<Avatar className={classes.avatar}>
<VpnKeyIcon/>
</Avatar>
<Typography component="h1" variant="h5">
Reset The Password
</Typography>
<br/>
<br/>
<Grid item xs={12} >
<h5 style={{justifyContent: 'center'}}>Enter The New Password For Your Account</h5>
<h5 style={{justifyContent: 'center'}}>Please Login In with Your New Password after Reset The Password !</h5>
</Grid>
<form className={classes.form} noValidate>
<Grid container spacing={2}>
<Grid item xs={12}>
<TextField
type="password"
variant="outlined"
required
fullWidth
id="password"
label="Enter Your New Password"
name="password"
autoComplete="password"
value={password}
onChange={e => setPassword(e.target.value)}
/>
</Grid>
<Grid item xs={12}>
{/*<FormControlLabel*/}
{/* control={<Checkbox value="allowExtraEmails" color="primary" />}*/}
{/* label="I want to receive inspiration, marketing promotions and updates via email."*/}
{/*/>*/}
</Grid>
</Grid>
<div style={{justifyContent: 'center'}}>
<Button
style={{maxWidth:"300px",marginRight:"20px",marginLeft:"120px",justifyContent: 'center'}}
type="submit"
variant="contained"
color="primary"
className={classes.submit}
onClick={handleClick}
>
Reset The Password
</Button>
</div>
<Grid container justify="flex-end">
{/*<Grid item xs>*/}
{/* <Link href="/sign-in" variant="body2">*/}
{/* Already have an account? Sign in*/}
{/* </Link>*/}
{/*</Grid>*/}
</Grid>
</form>
</div>
<Box mt={5}>
<Copyright />
</Box>
</Container>
);
}