refactor(server): moved the server files outside the src to improve static files
This commit is contained in:
16
server/services/auth/utils/checkPassword.ts
Normal file
16
server/services/auth/utils/checkPassword.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import bcrypt from "bcrypt";
|
||||
|
||||
export const checkPassword = async (currentPassword: string, dbPassword: string) => {
|
||||
let decyptPass = "";
|
||||
try {
|
||||
decyptPass = atob(dbPassword);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
// encypt password
|
||||
const pass: string | undefined = process.env.SECRET;
|
||||
|
||||
const checked = bcrypt.compareSync(pass + currentPassword, decyptPass);
|
||||
|
||||
return checked;
|
||||
};
|
||||
17
server/services/auth/utils/createPassword.ts
Normal file
17
server/services/auth/utils/createPassword.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import bcrypt from "bcrypt";
|
||||
|
||||
export const createPassword = async (password: string) => {
|
||||
// encypt password
|
||||
let pass: string | undefined = process.env.SECRET;
|
||||
let salt: string | undefined = process.env.SALTING;
|
||||
|
||||
if (!pass || !salt) {
|
||||
pass = "error";
|
||||
} else {
|
||||
pass = bcrypt.hashSync(pass + password, parseInt(salt));
|
||||
|
||||
pass = btoa(pass);
|
||||
}
|
||||
|
||||
return pass;
|
||||
};
|
||||
Reference in New Issue
Block a user