feat: implement user profile management with avatars, login, and personal data
- Add avatar upload functionality with public URL access. - Implement user login with email and password authentication. - Create endpoints for fetching and updating the authenticated user's profile. - Set up database migrations for user profiles, including email and role management. - Introduce personal data management linked to user profiles. - Add email verification process with welcome email templates.
This commit is contained in:
8
profiles/migrations/1_create_user_profiles.up.sql
Normal file
8
profiles/migrations/1_create_user_profiles.up.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE user_profiles (
|
||||
user_id TEXT PRIMARY KEY,
|
||||
display_name TEXT NOT NULL,
|
||||
bio TEXT NOT NULL DEFAULT '',
|
||||
avatar_url TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
10
profiles/migrations/2_user_id_uuid.up.sql
Normal file
10
profiles/migrations/2_user_id_uuid.up.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
DROP TABLE user_profiles;
|
||||
|
||||
CREATE TABLE user_profiles (
|
||||
user_id UUID PRIMARY KEY,
|
||||
display_name TEXT NOT NULL,
|
||||
bio TEXT NOT NULL DEFAULT '',
|
||||
avatar_url TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
10
profiles/migrations/3_add_auth.up.sql
Normal file
10
profiles/migrations/3_add_auth.up.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
ALTER TABLE user_profiles ADD COLUMN password_hash TEXT NOT NULL DEFAULT '';
|
||||
|
||||
CREATE TABLE sessions (
|
||||
token UUID PRIMARY KEY,
|
||||
user_id UUID NOT NULL REFERENCES user_profiles(user_id) ON DELETE CASCADE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
expires_at TIMESTAMPTZ NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX sessions_user_id_idx ON sessions (user_id);
|
||||
3
profiles/migrations/4_drop_auth_tables.up.sql
Normal file
3
profiles/migrations/4_drop_auth_tables.up.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
DROP TABLE sessions;
|
||||
|
||||
ALTER TABLE user_profiles DROP COLUMN password_hash;
|
||||
7
profiles/migrations/5_add_email.up.sql
Normal file
7
profiles/migrations/5_add_email.up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
ALTER TABLE user_profiles ADD COLUMN email TEXT NOT NULL DEFAULT '';
|
||||
|
||||
-- Existing rows predate the email column; give each a unique placeholder
|
||||
-- derived from its user ID so the uniqueness constraint below can apply.
|
||||
UPDATE user_profiles SET email = user_id || '@example.invalid' WHERE email = '';
|
||||
|
||||
CREATE UNIQUE INDEX user_profiles_email_idx ON user_profiles (email);
|
||||
1
profiles/migrations/6_add_role.up.sql
Normal file
1
profiles/migrations/6_add_role.up.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE user_profiles ADD COLUMN role TEXT NOT NULL DEFAULT 'user';
|
||||
1
profiles/migrations/7_add_status.up.sql
Normal file
1
profiles/migrations/7_add_status.up.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE user_profiles ADD COLUMN status SMALLINT NOT NULL DEFAULT 0;
|
||||
2
profiles/migrations/8_artist_profile.up.sql
Normal file
2
profiles/migrations/8_artist_profile.up.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE user_profiles DROP COLUMN bio;
|
||||
ALTER TABLE user_profiles ADD COLUMN is_artist BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
10
profiles/migrations/9_personal_data.up.sql
Normal file
10
profiles/migrations/9_personal_data.up.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE personal_data (
|
||||
user_id UUID PRIMARY KEY REFERENCES user_profiles (user_id) ON DELETE CASCADE,
|
||||
first_name TEXT NOT NULL DEFAULT '',
|
||||
last_name TEXT NOT NULL DEFAULT '',
|
||||
address TEXT NOT NULL DEFAULT '',
|
||||
city TEXT NOT NULL DEFAULT '',
|
||||
country TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
Reference in New Issue
Block a user