Skip to content

Commit

Permalink
publish release 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MustafaAhmed313 committed Sep 16, 2024
1 parent fd64be4 commit f2f2194
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const signUp = asyncWrapper(async(req, res, next) => {
const {
username,
email,
password
password,
phone
} = req.body;

if (!username || !email || !password) {
Expand All @@ -34,11 +35,11 @@ const signUp = asyncWrapper(async(req, res, next) => {
res.status(400).json(error);
}

const oldUser = await User.findOne({ $or:[{email: email}, {username: username}] });
const oldUser = await User.findOne({email: email});
if (oldUser) {
const error = appError.create(
STATUS.FAIL,
getErrorMessage(ERROR.UNIQUE, 'Email or Username')
getErrorMessage(ERROR.UNIQUE, 'Email')
);
res.status(400).json(error);
}
Expand All @@ -55,7 +56,8 @@ const signUp = asyncWrapper(async(req, res, next) => {
const user = new User({
username: username,
email: email,
password: hashedPassword
password: hashedPassword,
phone: phone
});
await user.save();

Expand Down
4 changes: 4 additions & 0 deletions models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const userSchema = new mongoose.Schema({
otp: {
type: String,
default: ''
},
phone: {
type: String,
default: "01234567890"
}
});

Expand Down

0 comments on commit f2f2194

Please sign in to comment.