chore: bump version to 2.23.2 and enhance team account creation (#440)
* chore: bump version to 2.23.2 and enhance team account creation - Updated application version from 2.23.1 to 2.23.2 in package.json. - Enhanced team account creation to support slugs for non-Latin names, including validation and UI updates. - Updated localization files to reflect new slug requirements and error messages. - Refactored related schemas and server actions to accommodate slug handling in team account creation and updates. * refactor: remove old trigger and function for adding current user to new account - Dropped the trigger "add_current_user_to_new_account" and the associated function from the database schema. - Updated permissions for the function public.create_team_account to ensure proper access control.
This commit is contained in:
committed by
GitHub
parent
e1bfbc8106
commit
0636f8cf11
@@ -1,20 +1,20 @@
|
||||
'use server';
|
||||
|
||||
import 'server-only';
|
||||
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { enhanceAction } from '@kit/next/actions';
|
||||
import { getLogger } from '@kit/shared/logger';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { CreateTeamSchema } from '../../schema/create-team.schema';
|
||||
import { createAccountCreationPolicyEvaluator } from '../policies';
|
||||
import { createCreateTeamAccountService } from '../services/create-team-account.service';
|
||||
|
||||
export const createTeamAccountAction = enhanceAction(
|
||||
async ({ name }, user) => {
|
||||
async ({ name, slug }, user) => {
|
||||
const logger = await getLogger();
|
||||
const client = getSupabaseServerClient();
|
||||
const service = createCreateTeamAccountService(client);
|
||||
const service = createCreateTeamAccountService();
|
||||
|
||||
const ctx = {
|
||||
name: 'team-accounts.create',
|
||||
@@ -52,12 +52,19 @@ export const createTeamAccountAction = enhanceAction(
|
||||
}
|
||||
}
|
||||
|
||||
// Service throws on error, so no need to check for error
|
||||
const { data } = await service.createNewOrganizationAccount({
|
||||
const { data, error } = await service.createNewOrganizationAccount({
|
||||
name,
|
||||
userId: user.id,
|
||||
slug,
|
||||
});
|
||||
|
||||
if (error === 'duplicate_slug') {
|
||||
return {
|
||||
error: true,
|
||||
message: 'teams:duplicateSlugError',
|
||||
};
|
||||
}
|
||||
|
||||
logger.info(ctx, `Team account created`);
|
||||
|
||||
const accountHomePath = '/home/' + data.slug;
|
||||
|
||||
Reference in New Issue
Block a user