-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: redirect to login or pricing page (#1550)
This should improve confusion experienced by new users.
- Loading branch information
Showing
5 changed files
with
51 additions
and
16 deletions.
There are no files selected for viewing
12 changes: 6 additions & 6 deletions
12
src/controllers/UploadController.test.ts → ...ntrollers/Upload/UploadController.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import express from 'express'; | ||
import { useDefaultEmailService } from '../../../services/EmailService/EmailService'; | ||
import UsersService from '../../../services/UsersService'; | ||
import UsersRepository from '../../../data_layer/UsersRepository'; | ||
import { getDatabase } from '../../../data_layer'; | ||
|
||
export const handleUploadLimitError = async ( | ||
req: express.Request, | ||
response: express.Response | ||
) => { | ||
const owner = response.locals.owner; | ||
|
||
// If the user is already logged in, redirect to the pricing page | ||
if (owner) { | ||
const database = getDatabase(); | ||
const emailService = useDefaultEmailService(); | ||
const usersService = new UsersService( | ||
new UsersRepository(database), | ||
emailService | ||
); | ||
|
||
const user = await usersService.getUserById(response.locals.owner); | ||
if (user) { | ||
return response.redirect('/pricing?error=upload_limit_exceeded'); | ||
} | ||
} | ||
|
||
response.redirect('/login?error=upload_limit_exceeded'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters