Change auth-token endpoint from GET to POST.

This commit is contained in:
Jonathan Bernard
2017-05-08 12:39:12 -05:00
parent 6aaca4a078
commit 781eeb6a13
2 changed files with 15 additions and 6 deletions

View File

@ -130,9 +130,16 @@ proc start*(cfg: StrawBossConfig): void =
get "/ping": resp($(%*"pong"), JSON)
get "/auth-token":
post "/auth-token":
var uname, pwd: string
try:
let authToken = makeAuthToken(cfg, @"username", @"password")
let jsonBody = parseJson(request.body)
uname = jsonBody["username"].getStr
pwd = jsonBody["password"].getStr
except: resp(Http400, makeJsonResp(Http400), JSON)
try:
let authToken = makeAuthToken(cfg, uname, pwd)
resp("\"" & $authToken & "\"", JSON)
except: resp(Http401, makeJsonResp(Http401, getCurrentExceptionMsg()), JSON)