sign up
parent
fdfd658fd0
commit
1880bd64b8
|
@ -19,6 +19,7 @@ import {
|
|||
CALENDAR_MAX_SERVICE_DURATION,
|
||||
CALENDAR_MIN_EARLIEST_BOOKING_TIME,
|
||||
EMAIL_VERIFICATION_STATE,
|
||||
PAYMENT_PLAN,
|
||||
PAYMENT_PLAN_SETTINGS,
|
||||
PAYMENT_PLAN_STATUS,
|
||||
Roles,
|
||||
|
@ -62,15 +63,12 @@ export async function SignUp(req: Request, res: Response) {
|
|||
try {
|
||||
let {
|
||||
companyName,
|
||||
companyAddress,
|
||||
username,
|
||||
email,
|
||||
password,
|
||||
language,
|
||||
rememberMe,
|
||||
recaptcha,
|
||||
paymentPlan,
|
||||
paymentInterval,
|
||||
companyAddress,
|
||||
} = req.body;
|
||||
|
||||
// validate request
|
||||
|
@ -85,12 +83,7 @@ export async function SignUp(req: Request, res: Response) {
|
|||
!isUsernameValid(username) ||
|
||||
!(await isEmailValid(email)) ||
|
||||
!isLanguageCodeValid(language) ||
|
||||
rememberMe === undefined ||
|
||||
!recaptcha ||
|
||||
paymentPlan === undefined ||
|
||||
!isPaymentPlanValid(paymentPlan) ||
|
||||
paymentInterval === undefined ||
|
||||
!isPaymentIntervalValid(paymentInterval) ||
|
||||
!isCompanyAddressValid(companyAddress)
|
||||
) {
|
||||
return res.status(400).send({ err: "invalid request" });
|
||||
|
@ -142,14 +135,14 @@ export async function SignUp(req: Request, res: Response) {
|
|||
owner_user_id: userId,
|
||||
name: companyName,
|
||||
calendar_max_future_booking_days:
|
||||
PAYMENT_PLAN_SETTINGS[paymentPlan].calendarMaxFutureBookingDays,
|
||||
PAYMENT_PLAN_SETTINGS[PAYMENT_PLAN.DEMO].calendarMaxFutureBookingDays,
|
||||
calendar_min_earliest_booking_time: CALENDAR_MIN_EARLIEST_BOOKING_TIME,
|
||||
calendar_max_service_duration: CALENDAR_MAX_SERVICE_DURATION,
|
||||
address: companyAddress,
|
||||
});
|
||||
|
||||
// create email verification
|
||||
/*
|
||||
|
||||
const emailVerificationId = newEmailVerificationId();
|
||||
const state = EMAIL_VERIFICATION_STATE.PENDING_EMAIL_VERIFICATION;
|
||||
|
||||
|
@ -161,7 +154,7 @@ export async function SignUp(req: Request, res: Response) {
|
|||
|
||||
rabbitmq.sendEmail(email, "dashboardSignUpEmailVerification", language, {
|
||||
emailVerificationUrl: getEmailVerificationUrl(state, emailVerificationId),
|
||||
}); */
|
||||
});
|
||||
|
||||
// create user
|
||||
|
||||
|
@ -175,10 +168,10 @@ export async function SignUp(req: Request, res: Response) {
|
|||
language: language,
|
||||
analytics_enabled: USER_ANALYTICS_ENABLED_DEFAULT,
|
||||
state: ACCOUNT_STATE.INIT_PAYMENT,
|
||||
payment_plan: paymentPlan,
|
||||
payment_plan_status: PAYMENT_PLAN_STATUS.TRAILING,
|
||||
payment_plan: PAYMENT_PLAN.DEMO,
|
||||
// payment_plan_status: PAYMENT_PLAN_STATUS.TRAILING,
|
||||
});
|
||||
|
||||
/*
|
||||
const checkoutSessionUrl = await CreateCheckoutSession(
|
||||
await getPriceId(paymentPlan, paymentInterval),
|
||||
userId
|
||||
|
@ -186,15 +179,24 @@ export async function SignUp(req: Request, res: Response) {
|
|||
|
||||
if (!checkoutSessionUrl) {
|
||||
return res.status(500).send({ err: "invalid request" });
|
||||
}
|
||||
} */
|
||||
|
||||
logger.info(
|
||||
`new user signed up: user_id: ${userId} email: ${email} language: ${language} company: ${companyName} username: ${username}`
|
||||
);
|
||||
|
||||
saveSession(req, res, userId, true, {
|
||||
res.status(200).send({ msg: "success" });
|
||||
|
||||
/*
|
||||
saveSession(
|
||||
req,
|
||||
res,
|
||||
userId,
|
||||
true
|
||||
, {
|
||||
redirectUrl: checkoutSessionUrl,
|
||||
});
|
||||
}
|
||||
);*/
|
||||
} catch (error) {
|
||||
logger.error("signup error", error as string);
|
||||
res.status(500).send({ err: "invalid request" });
|
||||
|
@ -481,7 +483,7 @@ export async function GetUser(req: Request, res: Response) {
|
|||
language: user.language,
|
||||
analytics_enabled: user.analytics_enabled,
|
||||
payment_plan: user.payment_plan,
|
||||
payment_plan_status: user.payment_plan_status,
|
||||
// payment_plan_status: user.payment_plan_status,
|
||||
payment_plan_trial_end: user.payment_plan_trial_end,
|
||||
payment_plan_canceled_at: user.payment_plan_canceled_at,
|
||||
},
|
||||
|
|
|
@ -18,7 +18,7 @@ interface UserAttributes {
|
|||
google_account_picture?: string;
|
||||
analytics_enabled: boolean;
|
||||
payment_plan: number;
|
||||
payment_plan_status?: string;
|
||||
// payment_plan_status?: string;
|
||||
payment_plan_trial_end?: number;
|
||||
payment_plan_canceled_at?: number;
|
||||
stripe_customer_id?: string;
|
||||
|
@ -40,7 +40,7 @@ class User extends Model<UserAttributes> implements UserAttributes {
|
|||
declare google_account_picture: string;
|
||||
declare analytics_enabled: boolean;
|
||||
declare payment_plan: number;
|
||||
declare payment_plan_status: string;
|
||||
// declare payment_plan_status: string;
|
||||
declare payment_plan_trial_end: number;
|
||||
declare payment_plan_canceled_at: number;
|
||||
declare stripe_customer_id: string;
|
||||
|
@ -111,10 +111,10 @@ User.init(
|
|||
type: DataTypes.TINYINT,
|
||||
allowNull: false,
|
||||
},
|
||||
payment_plan_status: {
|
||||
/*payment_plan_status: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
},
|
||||
}, */
|
||||
payment_plan_trial_end: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
|
|
|
@ -89,11 +89,18 @@ export const ACCOUNT_EXPORT_URL = `${DASHBOARD_URL}/api/v1/user/profile/export/`
|
|||
export const TERMIN_PLANNER_URL = process.env.TERMIN_PLANNER_URL;
|
||||
|
||||
export enum PAYMENT_PLAN {
|
||||
BASIC = 0,
|
||||
PREMIUM = 1,
|
||||
DEMO = 0,
|
||||
BASIC = 1,
|
||||
PREMIUM = 2,
|
||||
}
|
||||
|
||||
export const PAYMENT_PLAN_SETTINGS = [
|
||||
{
|
||||
id: "demo", // used in the backend for identifiying the stripe pricing product
|
||||
name: "Demo", // used in the frontend
|
||||
maxEmployees: 5,
|
||||
calendarMaxFutureBookingDays: 7,
|
||||
},
|
||||
{
|
||||
id: "basic", // used in the backend for identifiying the stripe pricing product
|
||||
name: "Basic", // used in the frontend
|
||||
|
|
Loading…
Reference in New Issue