731e297147
<img width="1418" height="804" alt="image" src="https://github.com/user-attachments/assets/de6c8222-6496-4a71-bc21-7e5e1269d5cb" /> --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com>
27 lines
718 B
TypeScript
27 lines
718 B
TypeScript
import { ConfigService } from '@/cli/utilities/config/config-service';
|
|
import { runSafe } from '@/cli/utilities/run-safe';
|
|
import { AUTH_ERROR_CODES, type CommandResult } from '@/cli/types';
|
|
|
|
export type AuthLogoutOptions = {
|
|
remote?: string;
|
|
};
|
|
|
|
const innerAuthLogout = async (
|
|
options?: AuthLogoutOptions,
|
|
): Promise<CommandResult> => {
|
|
if (options?.remote) {
|
|
ConfigService.setActiveRemote(options.remote);
|
|
}
|
|
|
|
const configService = new ConfigService();
|
|
|
|
await configService.clearConfig();
|
|
|
|
return { success: true, data: undefined };
|
|
};
|
|
|
|
export const authLogout = (
|
|
options?: AuthLogoutOptions,
|
|
): Promise<CommandResult> =>
|
|
runSafe(() => innerAuthLogout(options), AUTH_ERROR_CODES.AUTH_FAILED);
|