- Added user_invites table to manage invitation tokens. - Created invite router with procedures for sending, verifying, and accepting invites. - Implemented email sending functionality for invites. - Updated user controller to handle password setting during invite acceptance. - Introduced mustChangePassword flag in user schema and related logic. - Added middleware to enforce password change requirement. - Created forms for accepting invites and changing passwords. - Updated database migrations to reflect new user invite structure and fields.
23 lines
No EOL
689 B
SQL
23 lines
No EOL
689 B
SQL
--- user_invites table
|
|
CREATE TABLE IF NOT EXISTS public.user_invites (
|
|
id UUID DEFAULT gen_random_uuid () NOT NULL,
|
|
email TEXT NOT NULL,
|
|
token TEXT NOT NULL UNIQUE,
|
|
expires_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
|
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT now()
|
|
);
|
|
|
|
-- Primary Key
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1 FROM pg_constraint
|
|
WHERE conname = 'user_invites_pkey'
|
|
AND conrelid = 'public.user_invites'::regclass
|
|
) THEN
|
|
ALTER TABLE public.user_invites
|
|
ADD CONSTRAINT user_invites_pkey PRIMARY KEY (id);
|
|
END IF;
|
|
END $$;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_user_invites_token ON public.user_invites (token); |