fix: migrate remaining controllers from Auth0 sub to UUID identity (refs #220)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 3m40s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 24s
Deploy to Staging / Verify Staging (pull_request) Successful in 10s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 8s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 3m40s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 24s
Deploy to Staging / Verify Staging (pull_request) Successful in 10s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 8s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
16 controllers still used request.user.sub (Auth0 ID) instead of request.userContext.userId (UUID) after the user_id column migration, causing 500 errors on all authenticated endpoints including dashboard. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@ export class SubscriptionsController {
|
||||
*/
|
||||
async getSubscription(request: FastifyRequest, reply: FastifyReply): Promise<void> {
|
||||
try {
|
||||
const userId = (request as any).user.sub;
|
||||
const userId = request.userContext!.userId;
|
||||
|
||||
const subscription = await this.service.getSubscription(userId);
|
||||
|
||||
@@ -39,7 +39,7 @@ export class SubscriptionsController {
|
||||
reply.status(200).send(subscription);
|
||||
} catch (error: any) {
|
||||
logger.error('Failed to get subscription', {
|
||||
userId: (request as any).user?.sub,
|
||||
userId: request.userContext?.userId,
|
||||
error: error.message,
|
||||
});
|
||||
reply.status(500).send({
|
||||
@@ -54,14 +54,14 @@ export class SubscriptionsController {
|
||||
*/
|
||||
async checkNeedsVehicleSelection(request: FastifyRequest, reply: FastifyReply): Promise<void> {
|
||||
try {
|
||||
const userId = (request as any).user.sub;
|
||||
const userId = request.userContext!.userId;
|
||||
|
||||
const result = await this.service.checkNeedsVehicleSelection(userId);
|
||||
|
||||
reply.status(200).send(result);
|
||||
} catch (error: any) {
|
||||
logger.error('Failed to check needs vehicle selection', {
|
||||
userId: (request as any).user?.sub,
|
||||
userId: request.userContext?.userId,
|
||||
error: error.message,
|
||||
});
|
||||
reply.status(500).send({
|
||||
@@ -85,8 +85,8 @@ export class SubscriptionsController {
|
||||
reply: FastifyReply
|
||||
): Promise<void> {
|
||||
try {
|
||||
const userId = (request as any).user.sub;
|
||||
const email = (request as any).user.email;
|
||||
const userId = request.userContext!.userId;
|
||||
const email = request.userContext!.email || '';
|
||||
const { tier, billingCycle, paymentMethodId } = request.body;
|
||||
|
||||
// Validate inputs
|
||||
@@ -141,7 +141,7 @@ export class SubscriptionsController {
|
||||
reply.status(200).send(updatedSubscription);
|
||||
} catch (error: any) {
|
||||
logger.error('Failed to create checkout', {
|
||||
userId: (request as any).user?.sub,
|
||||
userId: request.userContext?.userId,
|
||||
error: error.message,
|
||||
});
|
||||
reply.status(500).send({
|
||||
@@ -156,14 +156,14 @@ export class SubscriptionsController {
|
||||
*/
|
||||
async cancelSubscription(request: FastifyRequest, reply: FastifyReply): Promise<void> {
|
||||
try {
|
||||
const userId = (request as any).user.sub;
|
||||
const userId = request.userContext!.userId;
|
||||
|
||||
const subscription = await this.service.cancelSubscription(userId);
|
||||
|
||||
reply.status(200).send(subscription);
|
||||
} catch (error: any) {
|
||||
logger.error('Failed to cancel subscription', {
|
||||
userId: (request as any).user?.sub,
|
||||
userId: request.userContext?.userId,
|
||||
error: error.message,
|
||||
});
|
||||
reply.status(500).send({
|
||||
@@ -178,14 +178,14 @@ export class SubscriptionsController {
|
||||
*/
|
||||
async reactivateSubscription(request: FastifyRequest, reply: FastifyReply): Promise<void> {
|
||||
try {
|
||||
const userId = (request as any).user.sub;
|
||||
const userId = request.userContext!.userId;
|
||||
|
||||
const subscription = await this.service.reactivateSubscription(userId);
|
||||
|
||||
reply.status(200).send(subscription);
|
||||
} catch (error: any) {
|
||||
logger.error('Failed to reactivate subscription', {
|
||||
userId: (request as any).user?.sub,
|
||||
userId: request.userContext?.userId,
|
||||
error: error.message,
|
||||
});
|
||||
reply.status(500).send({
|
||||
@@ -207,8 +207,8 @@ export class SubscriptionsController {
|
||||
reply: FastifyReply
|
||||
): Promise<void> {
|
||||
try {
|
||||
const userId = (request as any).user.sub;
|
||||
const email = (request as any).user.email;
|
||||
const userId = request.userContext!.userId;
|
||||
const email = request.userContext!.email || '';
|
||||
const { paymentMethodId } = request.body;
|
||||
|
||||
// Validate input
|
||||
@@ -228,7 +228,7 @@ export class SubscriptionsController {
|
||||
});
|
||||
} catch (error: any) {
|
||||
logger.error('Failed to update payment method', {
|
||||
userId: (request as any).user?.sub,
|
||||
userId: request.userContext?.userId,
|
||||
error: error.message,
|
||||
});
|
||||
reply.status(500).send({
|
||||
@@ -243,14 +243,14 @@ export class SubscriptionsController {
|
||||
*/
|
||||
async getInvoices(request: FastifyRequest, reply: FastifyReply): Promise<void> {
|
||||
try {
|
||||
const userId = (request as any).user.sub;
|
||||
const userId = request.userContext!.userId;
|
||||
|
||||
const invoices = await this.service.getInvoices(userId);
|
||||
|
||||
reply.status(200).send(invoices);
|
||||
} catch (error: any) {
|
||||
logger.error('Failed to get invoices', {
|
||||
userId: (request as any).user?.sub,
|
||||
userId: request.userContext?.userId,
|
||||
error: error.message,
|
||||
});
|
||||
reply.status(500).send({
|
||||
@@ -273,7 +273,7 @@ export class SubscriptionsController {
|
||||
reply: FastifyReply
|
||||
): Promise<void> {
|
||||
try {
|
||||
const userId = (request as any).user.sub;
|
||||
const userId = request.userContext!.userId;
|
||||
const { targetTier, vehicleIdsToKeep } = request.body;
|
||||
|
||||
// Validate inputs
|
||||
@@ -311,7 +311,7 @@ export class SubscriptionsController {
|
||||
reply.status(200).send(updatedSubscription);
|
||||
} catch (error: any) {
|
||||
logger.error('Failed to downgrade subscription', {
|
||||
userId: (request as any).user?.sub,
|
||||
userId: request.userContext?.userId,
|
||||
error: error.message,
|
||||
});
|
||||
reply.status(500).send({
|
||||
|
||||
Reference in New Issue
Block a user