mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
make confirm-email a post api
This commit is contained in:
parent
4c75260229
commit
ea9d98aa95
3 changed files with 8 additions and 6 deletions
|
|
@ -467,11 +467,11 @@ export function authRouter() {
|
|||
cors<express.Request>({ ...corsConfig, maxAge: 600 })
|
||||
)
|
||||
|
||||
router.get(
|
||||
'/confirm-email/:token',
|
||||
router.post(
|
||||
'/confirm-email',
|
||||
cors<express.Request>(corsConfig),
|
||||
async (req: express.Request, res: express.Response) => {
|
||||
const token = req.params.token
|
||||
const token = req.body.token
|
||||
|
||||
try {
|
||||
// verify token
|
||||
|
|
|
|||
|
|
@ -138,10 +138,10 @@ export const sendConfirmationEmail = async (user: {
|
|||
}): Promise<boolean> => {
|
||||
// generate confirmation link
|
||||
const confirmationToken = generateVerificationToken(user.id)
|
||||
const confirmationLink = `${env.client.url}/api/auth/confirm-email/${confirmationToken}`
|
||||
const confirmationLink = `${env.client.url}/confirm-email/${confirmationToken}`
|
||||
// send email
|
||||
return sendEmail({
|
||||
from: `Omnivore <${env.sender.message}>`,
|
||||
from: env.sender.message,
|
||||
to: user.email,
|
||||
subject: 'Confirm your email',
|
||||
text: `Hey ${user.name},\n\nPlease confirm your email by clicking the link below:\n\n${confirmationLink}\n\n`,
|
||||
|
|
|
|||
|
|
@ -263,17 +263,19 @@ describe('auth router', () => {
|
|||
|
||||
describe('confirm-email', () => {
|
||||
const confirmEmailRequest = (token: string): supertest.Test => {
|
||||
return request.get(`${route}/confirm-email/${token}`).send()
|
||||
return request.post(`${route}/confirm-email`).send({ token })
|
||||
}
|
||||
|
||||
let user: User
|
||||
let token: string
|
||||
|
||||
before(async () => {
|
||||
sinon.replace(util, 'sendEmail', sinon.fake.resolves(true))
|
||||
user = await createTestUser('pendingUser', undefined, 'password', true)
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
sinon.restore()
|
||||
await deleteTestUser(user.name)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue