chore: migrate user identity from auth0_sub to UUID #219

Merged
egullickson merged 10 commits from issue-206-migrate-user-identity-uuid into main 2026-02-16 20:55:41 +00:00
3 changed files with 7 additions and 7 deletions
Showing only changes of commit e9093138fa - Show all commits

View File

@@ -767,7 +767,7 @@ export class SubscriptionsService {
): Promise<void> { ): Promise<void> {
try { try {
// Get user profile for email and name // Get user profile for email and name
const userProfile = await this.userProfileRepository.getByAuth0Sub(userId); const userProfile = await this.userProfileRepository.getById(userId);
if (!userProfile) { if (!userProfile) {
logger.warn('User profile not found for tier change notification', { userId }); logger.warn('User profile not found for tier change notification', { userId });
return; return;
@@ -925,7 +925,7 @@ export class SubscriptionsService {
// Sync tier to user_profiles table (within same transaction) // Sync tier to user_profiles table (within same transaction)
await client.query( await client.query(
'UPDATE user_profiles SET subscription_tier = $1 WHERE auth0_sub = $2', 'UPDATE user_profiles SET subscription_tier = $1 WHERE id = $2',
[newTier, userId] [newTier, userId]
); );

View File

@@ -50,7 +50,7 @@ export async function processGracePeriodExpirations(): Promise<GracePeriodResult
up.notification_email, up.notification_email,
up.display_name up.display_name
FROM subscriptions s FROM subscriptions s
LEFT JOIN user_profiles up ON s.user_id = up.auth0_sub LEFT JOIN user_profiles up ON s.user_id = up.id
WHERE s.status = 'past_due' WHERE s.status = 'past_due'
AND s.grace_period_end < NOW() AND s.grace_period_end < NOW()
ORDER BY s.grace_period_end ASC ORDER BY s.grace_period_end ASC
@@ -89,13 +89,13 @@ export async function processGracePeriodExpirations(): Promise<GracePeriodResult
await client.query(updateQuery, [subscription.id]); await client.query(updateQuery, [subscription.id]);
// Sync tier to user_profiles table (user_id is auth0_sub) // Sync tier to user_profiles table
const syncQuery = ` const syncQuery = `
UPDATE user_profiles UPDATE user_profiles
SET SET
subscription_tier = 'free', subscription_tier = 'free',
updated_at = NOW() updated_at = NOW()
WHERE auth0_sub = $1 WHERE id = $1
`; `;
await client.query(syncQuery, [subscription.user_id]); await client.query(syncQuery, [subscription.user_id]);

View File

@@ -82,7 +82,7 @@ export class VehiclesService {
} }
// Get user's tier for limit enforcement // Get user's tier for limit enforcement
const userProfile = await this.userProfileRepository.getByAuth0Sub(userId); const userProfile = await this.userProfileRepository.getById(userId);
if (!userProfile) { if (!userProfile) {
throw new Error('User profile not found'); throw new Error('User profile not found');
} }
@@ -227,7 +227,7 @@ export class VehiclesService {
*/ */
async getUserVehiclesWithTierStatus(userId: string): Promise<Array<VehicleResponse & { tierStatus: 'active' | 'locked' }>> { async getUserVehiclesWithTierStatus(userId: string): Promise<Array<VehicleResponse & { tierStatus: 'active' | 'locked' }>> {
// Get user's subscription tier // Get user's subscription tier
const userProfile = await this.userProfileRepository.getByAuth0Sub(userId); const userProfile = await this.userProfileRepository.getById(userId);
if (!userProfile) { if (!userProfile) {
throw new Error('User profile not found'); throw new Error('User profile not found');
} }