fix company user registration
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { API_BASE_URL, getSignupFormSchema } from '@/app/actions/definitions';
|
import { API_BASE_URL, getSignupFormSchema } from '@/app/actions/definitions';
|
||||||
import { getSessionData } from '@/app/actions/session';
|
import { getSessionData } from '@/app/actions/session';
|
||||||
|
import { headers } from 'next/headers';
|
||||||
|
|
||||||
export type CompanyUserRegistrationFormState = {
|
export type CompanyUserRegistrationFormState = {
|
||||||
previousState: {
|
previousState: {
|
||||||
@@ -24,6 +25,8 @@ export async function companyUserRegistration(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const headersList = await headers();
|
||||||
|
|
||||||
const fullName = formData.get('fullName') as string || '';
|
const fullName = formData.get('fullName') as string || '';
|
||||||
const email = formData.get('email') as string || '';
|
const email = formData.get('email') as string || '';
|
||||||
const password = formData.get('password') as string || '';
|
const password = formData.get('password') as string || '';
|
||||||
@@ -32,6 +35,11 @@ export async function companyUserRegistration(
|
|||||||
|
|
||||||
const SignupFormSchema = await getSignupFormSchema('b2c');
|
const SignupFormSchema = await getSignupFormSchema('b2c');
|
||||||
|
|
||||||
|
const forwardedFor = headersList.get('x-forwarded-for');
|
||||||
|
const realIp = headersList.get('x-real-ip');
|
||||||
|
const ip = forwardedFor?.split(',')[0] || realIp || 'unknown';
|
||||||
|
const userAgent = headersList.get('user-agent') || 'unknown';
|
||||||
|
|
||||||
const dataToValidate = {
|
const dataToValidate = {
|
||||||
fullName,
|
fullName,
|
||||||
email,
|
email,
|
||||||
@@ -88,7 +96,9 @@ export async function companyUserRegistration(
|
|||||||
password,
|
password,
|
||||||
accountType: 'b2b',
|
accountType: 'b2b',
|
||||||
authToken: token,
|
authToken: token,
|
||||||
mail_verified: false
|
mail_verified: false,
|
||||||
|
ip: ip,
|
||||||
|
user_agent: userAgent,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
@@ -118,7 +128,9 @@ export async function companyUserRegistration(
|
|||||||
fullName: fullName,
|
fullName: fullName,
|
||||||
email,
|
email,
|
||||||
phone: phone,
|
phone: phone,
|
||||||
password
|
password,
|
||||||
|
ip: ip,
|
||||||
|
user_agent: userAgent,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user