-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.js
More file actions
43 lines (31 loc) · 668 Bytes
/
auth.js
File metadata and controls
43 lines (31 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Authentication and authorization
"use strict";
var _auth = (function(){
var url = require("url");
function auth(){
var that = this;
that.onAuthorization = function(){
var req = this.request,
res = this.response,
token;
//console.log(req.headers);
if(!!req.headers["csrf_token"]){
//console.log('token');
token = req.headers["csrf_token"];
_validateToken(token);
}else{
//console.log('token1');
return false;
}
};
//Private function
var _validateToken = function(token){
if(token === 'drapal'){
return true;
}
return false;
};
};
return auth;
})();
module.exports = new _auth();