status
This commit is contained in:
parent
3263b9d599
commit
4cbcc576a0
@ -9,7 +9,8 @@ import cloudinary from "cloudinary"
|
|||||||
import generator from 'generate-password'
|
import generator from 'generate-password'
|
||||||
|
|
||||||
// 1.Register a User
|
// 1.Register a User
|
||||||
export const registerUser = catchAsyncErrors(async (req, res, next) => {
|
export const registerUser = async (req, res, next) => {
|
||||||
|
try {
|
||||||
const files = req.files.avatar;
|
const files = req.files.avatar;
|
||||||
const myCloud = await cloudinary.uploader.upload(files.tempFilePath, {
|
const myCloud = await cloudinary.uploader.upload(files.tempFilePath, {
|
||||||
folder: "cmp-user/image",
|
folder: "cmp-user/image",
|
||||||
@ -29,7 +30,19 @@ export const registerUser = catchAsyncErrors(async (req, res, next) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
sendToken(user, 201, res);
|
sendToken(user, 201, res);
|
||||||
});
|
} catch (e) {
|
||||||
|
// console.log(e.message);
|
||||||
|
if (e.toString().includes('E11000 duplicate key error collection')) {
|
||||||
|
return res.status(400).json({
|
||||||
|
status: 'User Already Exists'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
.status(400)
|
||||||
|
.json({ status: 'Error Communicating with server' });
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
// 2.Login User
|
// 2.Login User
|
||||||
export const loginUser = catchAsyncErrors(async (req, res, next) => {
|
export const loginUser = catchAsyncErrors(async (req, res, next) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user