Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added confirm password in signup page #54

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions client/src/pages/SignUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const SignUpNew = () => {
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [cpassword, setcPassword] = useState("");
TheBaljitSingh marked this conversation as resolved.
Show resolved Hide resolved


const [avatar, setAvatar] = useState(null);
const [avatarError, setAvatarError] = useState(null);

Expand All @@ -39,6 +42,10 @@ const SignUpNew = () => {
const handlePasswordChange = (e) => {
setPassword(e.target.value);
};
const handlecPasswordChange = (e) => {
setcPassword(e.target.value);
};


const handleAvatarChange = (e) => {
const file = e.target.files[0];
Expand Down Expand Up @@ -75,6 +82,7 @@ const SignUpNew = () => {
formData.append("name", name);
formData.append("email", email);
formData.append("password", password);
formData.append("cpassword", cpassword);
formData.append("avatar", avatar);
formData.append("role", "general");
formData.append("isConsentGiven", isConsentGiven.toString());
Expand Down Expand Up @@ -261,6 +269,36 @@ const SignUpNew = () => {
autoComplete="off"
/>
</div>
{/* confirm password */}
<div className="relative mt-4 flex items-center">
<span className="absolute">
<svg
xmlns="http://www.w3.org/2000/svg"
className="mx-3 h-6 w-6 text-gray-300"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth={2}
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"
/>
</svg>
</span>
<input
id="cpassword"
name="cpassword"
type="password"
value={cpassword}
onChange={handlecPasswordChange}
className="block w-full rounded-lg border bg-white px-10 py-3 text-gray-700 focus:border-blue-400 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-40"
placeholder="Password"
required
autoComplete="off"
/>
</div>
<div className="mt-6">
<button
disabled={loading}
Expand Down
9 changes: 9 additions & 0 deletions client/src/redux/actions/authActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ export const signUpAction =
async (dispatch) => {
try {
localStorage.removeItem("profile");

if(formData.get('password')!==formData.get('cpassword')){
dispatch({
type: types.SIGNUP_FAIL,
payload: ["Password is not Matched"]
})
return;
}

const response = await api.signUp(formData);
const { error } = response;
if (error) {
Expand Down
27 changes: 0 additions & 27 deletions server/.env.example

This file was deleted.