mirror of
https://github.com/formbricks/formbricks.git
synced 2026-03-15 11:20:58 -05:00
* update prisma model to support user * add signup page * add email verification * remove seed user * update README and Dockerfile to support signup and the removal of seed data
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { hashPassword } from "./auth";
|
|
|
|
export const createUser = async (firstname, lastname, email, password) => {
|
|
const hashedPassword = await hashPassword(password);
|
|
try {
|
|
const res = await fetch(`/api/public/users`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
firstname,
|
|
lastname,
|
|
email,
|
|
password: hashedPassword,
|
|
}),
|
|
});
|
|
if (res.status !== 200) {
|
|
const json = await res.json();
|
|
throw Error(json.error);
|
|
}
|
|
return await res.json();
|
|
} catch (error) {
|
|
throw Error(`${error.message}`);
|
|
}
|
|
};
|
|
|
|
export const resendVerificationEmail = async (email) => {
|
|
try {
|
|
const res = await fetch(`/api/public/users/verfication-email`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
email,
|
|
}),
|
|
});
|
|
if (res.status !== 200) {
|
|
const json = await res.json();
|
|
throw Error(json.error);
|
|
}
|
|
return await res.json();
|
|
} catch (error) {
|
|
throw Error(`${error.message}`);
|
|
}
|
|
};
|