Skip to content
Snippets Groups Projects
Commit 036f1d88 authored by undefined's avatar undefined
Browse files

fix add staff endpoint

parent 2a1cc3af
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,30 @@ export const login = async (req: Request, res: Response) => {
};
export const addAccount = async (req: Request, res: Response) => {
const { username, password } = req.body;
const { username, password } = req.query;
if (typeof username !== "string") { //TODO: toto má byť asi niekde inde (dalsich 20 riadkov)
return res.status(400).json({
message: "Query param 'username' has to be of type string"
});
}
if (typeof password !== "string") {
return res.status(400).json({
message: "Query param 'password' has to be of type string"
});
}
const staff = await prisma.staff.findUnique({
where:{
username,
}
})
if(staff){
return res.status(400).json({
status: 'error',
message: 'username already exists'
});
}
bcrypt.hash(password, 10, async (err: any, hash: any) => {
if(err){
......
......@@ -26,7 +26,8 @@ export const authorizeStaff = (req: Request, res: Response, next: NextFunction)
};
export const validateStaffLogin = async (req: Request, res: Response, next: NextFunction) => {
const { username, password } = req.body;
const { username, password } = req.query;
if(!username || !password){
return res.status(400).json({
status: 'error',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment