Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 [confirmPassword, setconfirmPassword] = useState("");


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 handleconfirmPassword = (e) => {
setconfirmPassword(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("confirmPassword", confirmPassword);
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="confirmPassword"
name="confirmPassword"
type="password"
value={confirmPassword}
onChange={handleconfirmPassword}
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('confirmPassword')){
dispatch({
type: types.SIGNUP_FAIL,
payload: ["Password is not Matched"]
})
return;
}

const response = await api.signUp(formData);
const { error } = response;
if (error) {
Expand Down
6 changes: 3 additions & 3 deletions server/.env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CLIENT_URL=http://localhost:3000
MONGODB_URI=mongodb://127.0.0.1:27017/db_socialecho or MongoDB Atlas connection string
MONGODB_URI="mongodb://127.0.0.1:27017/db_socialecho"
PORT=4000

# JWT
SECRET=
REFRESH_SECRET=
SECRET="34f"
REFRESH_SECRET="43f"

# Crypto
CRYPTO_KEY=
Expand Down