Fix manual signup flow
Adjusted the manual signup flow to prevent users from being redirected to the profile completion page after logging in. This resolves an issue where users who registered manually were repeatedly prompted for information they had already provided.
This commit is contained in:
parent
dc896299ca
commit
13261836a0
@ -7,6 +7,11 @@ export type Json =
|
||||
| Json[]
|
||||
|
||||
export type Database = {
|
||||
// Allows to automatically instantiate createClient with right options
|
||||
// instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
|
||||
__InternalSupabase: {
|
||||
PostgrestVersion: "12.2.3 (519615d)"
|
||||
}
|
||||
public: {
|
||||
Tables: {
|
||||
"1001_amore_conselheira": {
|
||||
@ -561,6 +566,195 @@ export type Database = {
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
n8n_chat_dolceamore: {
|
||||
Row: {
|
||||
id: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
message?: Json
|
||||
session_id?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
n8n_chat_dolceamoree: {
|
||||
Row: {
|
||||
id: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
message?: Json
|
||||
session_id?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
n8n_chat_histories: {
|
||||
Row: {
|
||||
id: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
message?: Json
|
||||
session_id?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
n8n_chat_histories_primeade: {
|
||||
Row: {
|
||||
id: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
message?: Json
|
||||
session_id?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
n8n_chat_primevl: {
|
||||
Row: {
|
||||
id: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
message?: Json
|
||||
session_id?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
n8n_chat_qnn01: {
|
||||
Row: {
|
||||
id: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
message?: Json
|
||||
session_id?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
n8n_chat_recanto: {
|
||||
Row: {
|
||||
id: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
message?: Json
|
||||
session_id?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
n8n_chat_samambaia: {
|
||||
Row: {
|
||||
id: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
message?: Json
|
||||
session_id?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
n8n_fila_mensagens: {
|
||||
Row: {
|
||||
id: number
|
||||
id_mensagem: string
|
||||
mensagem: string
|
||||
telefone: string
|
||||
timestamp: string
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
id_mensagem: string
|
||||
mensagem: string
|
||||
telefone: string
|
||||
timestamp: string
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
id_mensagem?: string
|
||||
mensagem?: string
|
||||
telefone?: string
|
||||
timestamp?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
n8n_historico_mensagens: {
|
||||
Row: {
|
||||
created_at: string
|
||||
id: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Insert: {
|
||||
created_at?: string
|
||||
id?: number
|
||||
message: Json
|
||||
session_id: string
|
||||
}
|
||||
Update: {
|
||||
created_at?: string
|
||||
id?: number
|
||||
message?: Json
|
||||
session_id?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
pagamentos_mercadopago: {
|
||||
Row: {
|
||||
created_at: string
|
||||
@ -647,6 +841,24 @@ export type Database = {
|
||||
},
|
||||
]
|
||||
}
|
||||
profiles: {
|
||||
Row: {
|
||||
document_number: string | null
|
||||
full_name: string | null
|
||||
id: string
|
||||
}
|
||||
Insert: {
|
||||
document_number?: string | null
|
||||
full_name?: string | null
|
||||
id: string
|
||||
}
|
||||
Update: {
|
||||
document_number?: string | null
|
||||
full_name?: string | null
|
||||
id?: string
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
status_pagamento_mensal: {
|
||||
Row: {
|
||||
ano: number
|
||||
@ -792,10 +1004,10 @@ export type Database = {
|
||||
Returns: unknown
|
||||
}
|
||||
conselheiraamore: {
|
||||
Args: { query_embedding: string; match_count?: number; filter?: Json }
|
||||
Args: { filter?: Json; match_count?: number; query_embedding: string }
|
||||
Returns: {
|
||||
id: number
|
||||
content: string
|
||||
id: number
|
||||
metadata: Json
|
||||
similarity: number
|
||||
}[]
|
||||
@ -854,11 +1066,11 @@ export type Database = {
|
||||
}
|
||||
registrar_usuario: {
|
||||
Args:
|
||||
| { nome: string; empresa: string; email: string; senha: string }
|
||||
| { email: string; empresa: string; nome: string; senha: string }
|
||||
| {
|
||||
nome: string
|
||||
empresa: string
|
||||
email: string
|
||||
empresa: string
|
||||
nome: string
|
||||
senha: string
|
||||
whatsapp: string
|
||||
}
|
||||
@ -910,21 +1122,25 @@ export type Database = {
|
||||
}
|
||||
}
|
||||
|
||||
type DefaultSchema = Database[Extract<keyof Database, "public">]
|
||||
type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">
|
||||
|
||||
type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">]
|
||||
|
||||
export type Tables<
|
||||
DefaultSchemaTableNameOrOptions extends
|
||||
| keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
|
||||
| { schema: keyof Database },
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof Database
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
||||
Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
|
||||
? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
||||
DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
|
||||
: never = never,
|
||||
> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
|
||||
? (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
||||
Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
|
||||
> = DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
||||
DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
|
||||
Row: infer R
|
||||
}
|
||||
? R
|
||||
@ -942,14 +1158,16 @@ export type Tables<
|
||||
export type TablesInsert<
|
||||
DefaultSchemaTableNameOrOptions extends
|
||||
| keyof DefaultSchema["Tables"]
|
||||
| { schema: keyof Database },
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof Database
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
||||
: never = never,
|
||||
> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
|
||||
? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
||||
> = DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
||||
Insert: infer I
|
||||
}
|
||||
? I
|
||||
@ -965,14 +1183,16 @@ export type TablesInsert<
|
||||
export type TablesUpdate<
|
||||
DefaultSchemaTableNameOrOptions extends
|
||||
| keyof DefaultSchema["Tables"]
|
||||
| { schema: keyof Database },
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof Database
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
||||
: never = never,
|
||||
> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
|
||||
? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
||||
> = DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
||||
Update: infer U
|
||||
}
|
||||
? U
|
||||
@ -988,14 +1208,16 @@ export type TablesUpdate<
|
||||
export type Enums<
|
||||
DefaultSchemaEnumNameOrOptions extends
|
||||
| keyof DefaultSchema["Enums"]
|
||||
| { schema: keyof Database },
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
EnumName extends DefaultSchemaEnumNameOrOptions extends {
|
||||
schema: keyof Database
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
|
||||
: never = never,
|
||||
> = DefaultSchemaEnumNameOrOptions extends { schema: keyof Database }
|
||||
? Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
|
||||
> = DefaultSchemaEnumNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
|
||||
: DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
|
||||
? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
|
||||
: never
|
||||
@ -1003,14 +1225,16 @@ export type Enums<
|
||||
export type CompositeTypes<
|
||||
PublicCompositeTypeNameOrOptions extends
|
||||
| keyof DefaultSchema["CompositeTypes"]
|
||||
| { schema: keyof Database },
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
|
||||
schema: keyof Database
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
|
||||
? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
|
||||
: never = never,
|
||||
> = PublicCompositeTypeNameOrOptions extends { schema: keyof Database }
|
||||
? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
|
||||
> = PublicCompositeTypeNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
|
||||
: PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
|
||||
? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
|
||||
: never
|
||||
|
||||
@ -131,70 +131,87 @@ const CompleteProfile = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-screen bg-gray-50 px-4">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader className="space-y-1 text-center">
|
||||
<CardTitle className="text-2xl font-bold">Complete seu Perfil</CardTitle>
|
||||
<CardDescription>
|
||||
Para continuar, precisamos de algumas informações obrigatórias para configurar sua conta
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="nome">Nome Completo *</Label>
|
||||
<Input
|
||||
id="nome"
|
||||
type="text"
|
||||
placeholder="Seu nome completo"
|
||||
value={nome}
|
||||
onChange={(e) => setNome(e.target.value)}
|
||||
required
|
||||
disabled={isLoading}
|
||||
/>
|
||||
</div>
|
||||
<div className="min-h-screen bg-gradient-to-br from-background via-primary/5 to-accent/10 flex items-center justify-center p-4">
|
||||
<div className="w-full max-w-md">
|
||||
<Card className="glass-card border-white/10 backdrop-blur-xl bg-white/80 dark:bg-gray-900/80 shadow-2xl">
|
||||
<CardHeader className="space-y-2 text-center pb-6">
|
||||
<CardTitle className="text-2xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
Complete seu Perfil
|
||||
</CardTitle>
|
||||
<CardDescription className="text-muted-foreground/80">
|
||||
Para continuar, precisamos de algumas informações obrigatórias para configurar sua conta
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
<form onSubmit={handleSubmit} className="space-y-5">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="nome" className="text-sm font-medium text-foreground/90">
|
||||
Nome Completo *
|
||||
</Label>
|
||||
<Input
|
||||
id="nome"
|
||||
type="text"
|
||||
placeholder="Seu nome completo"
|
||||
value={nome}
|
||||
onChange={(e) => setNome(e.target.value)}
|
||||
required
|
||||
disabled={isLoading}
|
||||
className="glass-input border-white/20 bg-white/50 backdrop-blur-sm focus:border-primary/50 focus:ring-primary/20"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="empresa">Empresa (Opcional)</Label>
|
||||
<Input
|
||||
id="empresa"
|
||||
type="text"
|
||||
placeholder="Nome da sua empresa"
|
||||
value={empresa}
|
||||
onChange={(e) => setEmpresa(e.target.value)}
|
||||
disabled={isLoading}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="empresa" className="text-sm font-medium text-foreground/90">
|
||||
Empresa (Opcional)
|
||||
</Label>
|
||||
<Input
|
||||
id="empresa"
|
||||
type="text"
|
||||
placeholder="Nome da sua empresa"
|
||||
value={empresa}
|
||||
onChange={(e) => setEmpresa(e.target.value)}
|
||||
disabled={isLoading}
|
||||
className="glass-input border-white/20 bg-white/50 backdrop-blur-sm focus:border-primary/50 focus:ring-primary/20"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="whatsapp">WhatsApp *</Label>
|
||||
<Input
|
||||
id="whatsapp"
|
||||
type="tel"
|
||||
placeholder="(11) 99999-9999"
|
||||
value={whatsapp}
|
||||
onChange={(e) => handleWhatsappChange(e.target.value)}
|
||||
required
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="whatsapp" className="text-sm font-medium text-foreground/90">
|
||||
WhatsApp *
|
||||
</Label>
|
||||
<Input
|
||||
id="whatsapp"
|
||||
type="tel"
|
||||
placeholder="(11) 99999-9999"
|
||||
value={whatsapp}
|
||||
onChange={(e) => handleWhatsappChange(e.target.value)}
|
||||
required
|
||||
disabled={isLoading}
|
||||
className="glass-input border-white/20 bg-white/50 backdrop-blur-sm focus:border-primary/50 focus:ring-primary/20"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground/70">
|
||||
Necessário para integração com WhatsApp e notificações
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full glass-button bg-gradient-to-r from-primary to-accent hover:shadow-lg hover:shadow-primary/25 transition-all duration-300"
|
||||
disabled={isLoading}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Necessário para integração com WhatsApp e notificações
|
||||
>
|
||||
{isLoading ? "Salvando..." : "Completar Perfil"}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="glass-card p-4 border-primary/10 bg-primary/5">
|
||||
<p className="text-sm text-primary/90">
|
||||
<strong className="text-primary">Por que estes dados?</strong><br />
|
||||
Nome e WhatsApp são necessários para configurar automaticamente seu workspace e integrações personalizadas.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button type="submit" className="w-full" disabled={isLoading}>
|
||||
{isLoading ? "Salvando..." : "Completar Perfil"}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="mt-4 p-3 bg-blue-50 rounded-lg">
|
||||
<p className="text-sm text-blue-800">
|
||||
<strong>Por que estes dados?</strong><br />
|
||||
Nome e WhatsApp são necessários para configurar automaticamente seu workspace e integrações personalizadas.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
-- Criar trigger para automaticamente criar usuário na tabela usuarios quando se cadastra manualmente
|
||||
CREATE OR REPLACE FUNCTION public.handle_manual_user_signup()
|
||||
RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
SET search_path = public
|
||||
AS $$
|
||||
BEGIN
|
||||
-- Verificar se o usuário tem dados completos no raw_user_meta_data (cadastro manual)
|
||||
IF NEW.raw_user_meta_data IS NOT NULL AND
|
||||
NEW.raw_user_meta_data->>'nome' IS NOT NULL AND
|
||||
NEW.raw_user_meta_data->>'whatsapp' IS NOT NULL AND
|
||||
NEW.email IS NOT NULL THEN
|
||||
|
||||
-- Inserir na tabela usuarios
|
||||
INSERT INTO public.usuarios (id, email, nome, empresa, whatsapp)
|
||||
VALUES (
|
||||
NEW.id,
|
||||
NEW.email,
|
||||
NEW.raw_user_meta_data->>'nome',
|
||||
COALESCE(NEW.raw_user_meta_data->>'empresa', ''),
|
||||
NEW.raw_user_meta_data->>'whatsapp'
|
||||
)
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
nome = EXCLUDED.nome,
|
||||
empresa = EXCLUDED.empresa,
|
||||
whatsapp = EXCLUDED.whatsapp,
|
||||
email = EXCLUDED.email;
|
||||
|
||||
RETURN NEW;
|
||||
END IF;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- Criar trigger que será executado quando um usuário é inserido na tabela auth.users
|
||||
DROP TRIGGER IF EXISTS on_auth_user_created_manual ON auth.users;
|
||||
CREATE TRIGGER on_auth_user_created_manual
|
||||
AFTER INSERT ON auth.users
|
||||
FOR EACH ROW EXECUTE FUNCTION public.handle_manual_user_signup();
|
||||
Loading…
Reference in New Issue
Block a user