Improve user authentication and bid data handling
Standardizes user ID retrieval across multiple API endpoints and formats bid amount to string in the client. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 069d4324-6c40-4355-955e-c714a50de1ea Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3df548ff-50ae-432f-9be4-25d34eccc983/069d4324-6c40-4355-955e-c714a50de1ea/YptCfK0
This commit is contained in:
@ -180,7 +180,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
app.post('/api/auctions/:id/bid', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
const userId = req.user.claims.sub;
|
||||
const userId = req.user.claims?.sub || req.user.id;
|
||||
const bidData = insertBidSchema.parse({
|
||||
...req.body,
|
||||
auctionId: req.params.id,
|
||||
@ -207,7 +207,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
return res.status(404).json({ message: "No active auction found for this media outlet" });
|
||||
}
|
||||
|
||||
const userId = req.user.claims.sub;
|
||||
const userId = req.user.claims?.sub || req.user.id;
|
||||
const bidData = insertBidSchema.parse({
|
||||
...req.body,
|
||||
auctionId: auction.id,
|
||||
@ -225,7 +225,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Prediction market betting endpoints
|
||||
app.post('/api/prediction-markets/:marketId/bets', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
const userId = req.user.claims.sub;
|
||||
const userId = req.user.claims?.sub || req.user.id;
|
||||
const { side, amount } = req.body;
|
||||
|
||||
// Validate request
|
||||
@ -258,7 +258,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Media outlet request routes
|
||||
app.get('/api/media-outlet-requests', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
const userId = req.user.claims.sub;
|
||||
const userId = req.user.claims?.sub || req.user.id;
|
||||
const user = await storage.getUser(userId);
|
||||
|
||||
if (!user || user.role !== 'superadmin') {
|
||||
@ -276,7 +276,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
app.post('/api/media-outlet-requests', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
const userId = req.user.claims.sub;
|
||||
const userId = req.user.claims?.sub || req.user.id;
|
||||
const requestData = insertMediaOutletRequestSchema.parse({
|
||||
...req.body,
|
||||
requesterId: userId
|
||||
@ -292,7 +292,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
app.patch('/api/media-outlet-requests/:id', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
const userId = req.user.claims.sub;
|
||||
const userId = req.user.claims?.sub || req.user.id;
|
||||
const user = await storage.getUser(userId);
|
||||
|
||||
if (!user || user.role !== 'superadmin') {
|
||||
@ -321,7 +321,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
app.post('/api/articles/:articleId/comments', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
const userId = req.user.claims.sub;
|
||||
const userId = req.user.claims?.sub || req.user.id;
|
||||
const commentData = insertCommentSchema.parse({
|
||||
...req.body,
|
||||
articleId: req.params.articleId,
|
||||
@ -339,7 +339,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Analytics routes
|
||||
app.get('/api/analytics', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
const userId = req.user.claims.sub;
|
||||
const userId = req.user.claims?.sub || req.user.id;
|
||||
const user = await storage.getUser(userId);
|
||||
|
||||
if (!user || (user.role !== 'admin' && user.role !== 'superadmin')) {
|
||||
|
||||
Reference in New Issue
Block a user