Skip to content

Commit

Permalink
fixed: error
Browse files Browse the repository at this point in the history
  • Loading branch information
shinevue committed Jul 9, 2023
1 parent f68341d commit a9671a4
Show file tree
Hide file tree
Showing 5 changed files with 591 additions and 13 deletions.
15 changes: 5 additions & 10 deletions client/public/regist/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,20 @@ import { useAppSelector, useAppDispatch } from "../../src/app/hooks";
import { registerUser } from "../../src/action/authAction";
import { TypeRegisterData } from "../../src/action/actionType";

const Registere = () => {
const Register = () => {
const [userdata, setuserdata] = useState<TypeRegisterData>({
name: "",
email: "",
password: "",
repassword: "",
confirm: "",
});
const dispatch = useAppDispatch();
const onchange = (e: React.ChangeEvent<HTMLInputElement>) => {
console.log(e.target.value);
setuserdata({ ...userdata, [e.target.name]: e.target.value });
};
const onsubmit = (e: FormEvent) => {
e.preventDefault();
console.log(userdata);

console.log("onSubmit");

dispatch(registerUser(userdata));
if (userdata.password === userdata.confirm) dispatch(registerUser(userdata));
};

return (
Expand Down Expand Up @@ -65,7 +60,7 @@ const Registere = () => {
<div className="w-full m-6">
<TextField
className="w-full"
name="repassword"
name="confirm"
type="password"
id="outlined-basic"
label="Re-password:"
Expand All @@ -82,4 +77,4 @@ const Registere = () => {
);
};

export default Registere;
export default Register;
3 changes: 1 addition & 2 deletions controller/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const jwt = require("jsonwebtoken");
exports.register = async (req, res) => {
const { name, email, password, confirm } = req.body;
const isvalied = User.findOne({ email: email });
console.log(isvalied);
// console.log(isvalied);
if (!isvalied.name) {
const salt = await bcrypt.genSalt(10);
const hashedpassword = await bcrypt.hash(password, salt);
Expand All @@ -30,7 +30,6 @@ exports.register = async (req, res) => {
}
};
exports.login = async (req, res) => {
console.log(req.body);
const { email, password } = req.body;
const user = await User.findOne({ email: email });
if (user && (await bcrypt.compare(password, user.password))) {
Expand Down
Loading

0 comments on commit a9671a4

Please sign in to comment.