UnschooledGamer commited on
Commit
0cdcff9
·
verified ·
1 Parent(s): 06d41ac

Create auth.lua

Browse files
Files changed (1) hide show
  1. auth.lua +14 -0
auth.lua ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ local json = require("json")
2
+ local config = require('../utils/config')
3
+
4
+ return function(req, res, go)
5
+ local pass = req.headers["authorization"]
6
+
7
+ if pass ~= config.server.password then
8
+ res.body = json.encode({ error = "Authorization failed" })
9
+ res.code = 401
10
+ res.headers["Content-Type"] = "application/json"
11
+ return
12
+ end
13
+ go()
14
+ end