This repository has been archived by the owner on Jul 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
167 additions
and
156 deletions.
There are no files selected for viewing
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
40 changes: 0 additions & 40 deletions
40
src/migrations/20200212152821-create-verification-token.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import express from 'express'; | ||
import AuthController from '../controllers/authController'; | ||
import verificationController from '../controllers/verificationController'; | ||
import validateParams from '../validation/validateParams'; | ||
import validationResult from '../validation/validationResult'; | ||
import signupInputRules from '../validation/validationRules'; | ||
import verificationController from '../controllers/verificationController'; | ||
|
||
|
||
const authRouter = express.Router(); | ||
|
||
authRouter.post('/register', signupInputRules, validationResult, AuthController.registerUser); | ||
authRouter.get('/verification', verificationController.verifyAccount); | ||
authRouter.get('/verification', validateParams.validateToken, verificationController.verifyAccount); | ||
authRouter.post('/login', AuthController.login); | ||
|
||
export default authRouter; |
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,53 @@ | ||
import chai from 'chai'; | ||
import chaiHttp from 'chai-http'; | ||
import index from '../index'; | ||
import { | ||
email, | ||
id, | ||
isVerified, | ||
wrongEmail, | ||
wrongId | ||
} from './verifyAccountMock'; | ||
import provideToken from '../utils/provideToken'; | ||
|
||
const token = provideToken(id, isVerified, email); | ||
const wrongToken = provideToken(wrongId, isVerified, wrongEmail); | ||
|
||
|
||
const { | ||
expect | ||
} = chai; | ||
chai.use(chaiHttp); | ||
|
||
describe('Verification tests', () => { | ||
it('should return account verified created sucessfully.', (done) => { | ||
chai.request(index) | ||
.get(`/api/v1/auth/verification?token=${token}&email=${email}`) | ||
.end((err, res) => { | ||
expect(res.body).to.be.an('object'); | ||
expect(res.status).to.equal(200); | ||
expect(res.body.message).to.equal(`User with ${email} has been verified`); | ||
done(); | ||
}); | ||
}); | ||
it('should return account is already verified.', (done) => { | ||
chai.request(index) | ||
.get(`/api/v1/auth/verification?token=${token}&email=${email}`) | ||
.end((err, res) => { | ||
expect(res.body).to.be.an('object'); | ||
expect(res.status).to.equal(202); | ||
expect(res.body.message).to.equal(`${email} is already verified`); | ||
done(); | ||
}); | ||
}); | ||
it('should return you are not authorized to access this page..', (done) => { | ||
chai.request(index) | ||
.get(`/api/v1/auth/verification?token=${wrongToken}&email=${email}`) | ||
.end((err, res) => { | ||
expect(res.body).to.be.an('object'); | ||
expect(res.status).to.equal(401); | ||
expect(res.body.error).to.equal('Sorry, you are not authorized to access this page.'); | ||
done(); | ||
}); | ||
}); | ||
}); |
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,5 @@ | ||
export const email = 'jean@andela.com'; | ||
export const isVerified = false; | ||
export const id = '712cc013-275d-4855-b2ac-77c054ad3d28'; | ||
export const wrongEmail = 'jim@andela.com'; | ||
export const wrongId = '712cc013-275d-4855-b2ac-77c054ad3d29'; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.