-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from Cavdy/bg-credit-debit-transaction-accept…
…s-string-165638356 #165638356 Bug credit and debit transaction accepts string
- Loading branch information
Showing
13 changed files
with
665 additions
and
684 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 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
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
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,62 +1,78 @@ | ||
import jwt from 'jsonwebtoken'; | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
const jwtMiddleware = { | ||
/** | ||
* Check Token | ||
* @constructor | ||
* @param {*} req - get request. | ||
* @param {*} res -get response | ||
* @param {*} next - run next | ||
*/ | ||
checkToken(req, res, next) { | ||
const header = req.headers.authorization; | ||
if (typeof header !== 'undefined') { | ||
const bearer = header.split(' '); | ||
const token = bearer[1]; | ||
req.token = token; | ||
next(); | ||
} else { | ||
// If header is undefined return Forbidden (403) | ||
res.sendStatus(403); | ||
} | ||
}, | ||
|
||
/** | ||
* Signin Jwt | ||
* @constructor | ||
* @param {*} req - get request. | ||
* @param {*} res -get response | ||
* @param {*} next - run next | ||
*/ | ||
signinJwt(req, res, next) { | ||
jwt.sign(req.body, process.env.JWTSECRETKEY, async (err, token) => { | ||
if (err) { | ||
return res.sendStatus(403); | ||
} | ||
req.signintoken = token; | ||
return next(); | ||
}); | ||
}, | ||
|
||
/** | ||
* Verify Jwt | ||
* @constructor | ||
* @param {*} req - get request. | ||
* @param {*} res -get response | ||
* @param {*} next - run next | ||
*/ | ||
verifyJwt(req, res, next) { | ||
jwt.verify(req.token, process.env.JWTSECRETKEY, (err, authorizedData) => { | ||
if (err) { | ||
return res.sendStatus(403); | ||
} | ||
req.authorizedData = authorizedData; | ||
return next(); | ||
}); | ||
}, | ||
}; | ||
|
||
export default jwtMiddleware; | ||
import jwt from 'jsonwebtoken'; | ||
import dotenv from 'dotenv'; | ||
import statusHelper from '../helper/statusHelper'; | ||
|
||
dotenv.config(); | ||
|
||
const jwtMiddleware = { | ||
/** | ||
* Check Token | ||
* @constructor | ||
* @param {*} req - get request. | ||
* @param {*} res -get response | ||
* @param {*} next - run next | ||
*/ | ||
checkToken(req, res, next) { | ||
const header = req.headers.authorization; | ||
if (typeof header !== 'undefined') { | ||
const bearer = header.split(' '); | ||
const token = bearer[1]; | ||
req.token = token; | ||
next(); | ||
} else { | ||
// If header is undefined return Forbidden (403) | ||
return statusHelper | ||
.statusHelper(req, | ||
res, | ||
403, | ||
'you are not logged in', | ||
''); | ||
} | ||
}, | ||
|
||
/** | ||
* Signin Jwt | ||
* @constructor | ||
* @param {*} req - get request. | ||
* @param {*} res -get response | ||
* @param {*} next - run next | ||
*/ | ||
signinJwt(req, res, next) { | ||
jwt.sign(req.body, process.env.JWTSECRETKEY, async (err, token) => { | ||
if (err) { | ||
return statusHelper | ||
.statusHelper(req, | ||
res, | ||
403, | ||
'you are not logged in', | ||
''); | ||
} | ||
req.signintoken = token; | ||
return next(); | ||
}); | ||
}, | ||
|
||
/** | ||
* Verify Jwt | ||
* @constructor | ||
* @param {*} req - get request. | ||
* @param {*} res -get response | ||
* @param {*} next - run next | ||
*/ | ||
verifyJwt(req, res, next) { | ||
jwt.verify(req.token, process.env.JWTSECRETKEY, (err, authorizedData) => { | ||
if (err) { | ||
return statusHelper | ||
.statusHelper(req, | ||
res, | ||
403, | ||
'invalid token', | ||
''); | ||
} | ||
req.authorizedData = authorizedData; | ||
return next(); | ||
}); | ||
}, | ||
}; | ||
|
||
export default jwtMiddleware; |
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.