MCPcopy
hub / github.com/dwyl/learn-json-web-tokens / authHandler

Function authHandler

example/lib/helpers.js:78–94  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

76
77// handle authorisation requests
78function authHandler(req, res){
79 if (req.method === 'POST') {
80 var body = '';
81 req.on('data', function (data) {
82 body += data;
83 }).on('end', function () {
84 var post = qs.parse(body);
85 if(post.username && post.username === u.un && post.password && post.password === u.pw) {
86 return authSuccess(req, res);
87 } else {
88 return authFail(res);
89 }
90 });
91 } else {
92 return authFail(res);
93 }
94}
95
96function verify(token) {
97 var decoded = false;

Callers

nothing calls this directly

Calls 2

authSuccessFunction · 0.85
authFailFunction · 0.85

Tested by

no test coverage detected