feat(MED-85): create customer group for company account in Medusa
This commit is contained in:
@@ -281,6 +281,7 @@ export type Database = {
|
||||
primary_owner_user_id: string
|
||||
public_data: Json
|
||||
slug: string | null
|
||||
medusa_account_id: string | null
|
||||
updated_at: string | null
|
||||
updated_by: string | null
|
||||
}
|
||||
@@ -302,6 +303,7 @@ export type Database = {
|
||||
primary_owner_user_id?: string
|
||||
public_data?: Json
|
||||
slug?: string | null
|
||||
medusa_account_id?: string | null
|
||||
updated_at?: string | null
|
||||
updated_by?: string | null
|
||||
}
|
||||
@@ -323,6 +325,7 @@ export type Database = {
|
||||
primary_owner_user_id?: string
|
||||
public_data?: Json
|
||||
slug?: string | null
|
||||
medusa_account_id?: string | null
|
||||
updated_at?: string | null
|
||||
updated_by?: string | null
|
||||
}
|
||||
|
||||
@@ -20,15 +20,20 @@ export function useSignInWithEmailPassword() {
|
||||
const identities = user?.identities ?? [];
|
||||
|
||||
if (identities.length === 0) {
|
||||
throw new Error('User already registered');
|
||||
throw new Error('Invalid user');
|
||||
}
|
||||
|
||||
if ('email' in credentials) {
|
||||
try {
|
||||
await medusaLoginOrRegister({
|
||||
const medusaAccountId = await medusaLoginOrRegister({
|
||||
email: credentials.email,
|
||||
password: credentials.password,
|
||||
});
|
||||
await client
|
||||
.schema('medreport').from('accounts')
|
||||
.update({ medusa_account_id: medusaAccountId })
|
||||
.eq('primary_owner_user_id', user.id)
|
||||
.eq('is_personal_account', true);
|
||||
} catch (error) {
|
||||
await client.auth.signOut();
|
||||
throw error;
|
||||
|
||||
@@ -39,10 +39,15 @@ export function useSignUpWithEmailAndPassword() {
|
||||
|
||||
if ('email' in credentials) {
|
||||
try {
|
||||
await medusaLoginOrRegister({
|
||||
const medusaAccountId = await medusaLoginOrRegister({
|
||||
email: credentials.email,
|
||||
password: credentials.password,
|
||||
});
|
||||
await client
|
||||
.schema('medreport').from('accounts')
|
||||
.update({ medusa_account_id: medusaAccountId })
|
||||
.eq('primary_owner_user_id', user!.id)
|
||||
.eq('is_personal_account', true);
|
||||
} catch (error) {
|
||||
await client.auth.signOut();
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user