From 6098e1b0ee2b0567d244a5f513ed69fa9e1b918b Mon Sep 17 00:00:00 2001 From: lxsang Date: Wed, 10 Oct 2018 14:35:00 +0200 Subject: [PATCH] fix request bug --- blog/controllers/ServiceController.lua | 8 ++++---- grs/sendmail.lua | 4 ++-- grs/subscribe.lua | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/blog/controllers/ServiceController.lua b/blog/controllers/ServiceController.lua index aa97ea4..996e58d 100644 --- a/blog/controllers/ServiceController.lua +++ b/blog/controllers/ServiceController.lua @@ -17,10 +17,10 @@ function result(obj) end function ServiceController:sendmail() - if not REQUEST.query.json then + if not REQUEST.json then fail("unknown request") end - local rq = (JSON.decodeString(REQUEST.query.json)) + local rq = (JSON.decodeString(REQUEST.json)) local to = "xsang.le@gmail.com" local from = "From: " .. rq.email .. "\n" local suject = "Subject: " .. rq.subject .. "\n" @@ -40,10 +40,10 @@ function ServiceController:sendmail() end function ServiceController:subscribe() - if not REQUEST.query.json then + if not REQUEST.json then fail("unknown request") end - local rq = (JSON.decodeString(REQUEST.query.json)) + local rq = (JSON.decodeString(REQUEST.json)) -- check if email is exist local data = self.subscribers:find({exp = {["="] = {email = rq.email}}}) if data and #data > 0 then diff --git a/grs/sendmail.lua b/grs/sendmail.lua index 53b011a..7166475 100644 --- a/grs/sendmail.lua +++ b/grs/sendmail.lua @@ -1,8 +1,8 @@ -if not REQUEST.query.json then +if not REQUEST.json then fail("unknown request") end -local rq = (JSON.decodeString(REQUEST.query.json)) +local rq = (JSON.decodeString(REQUEST.json)) local to = "xsang.le@gmail.com" local from = "From: "..rq.email.."\n" local suject = "Subject: "..rq.subject.."\n" diff --git a/grs/subscribe.lua b/grs/subscribe.lua index ef70e6a..d614b1c 100644 --- a/grs/subscribe.lua +++ b/grs/subscribe.lua @@ -1,8 +1,8 @@ -if not REQUEST.query.json then +if not REQUEST.json then fail("unknown request") end -local rq = (JSON.decodeString(REQUEST.query.json)) +local rq = (JSON.decodeString(REQUEST.json)) local sample = {name = "toto", email = "toto@mail.fr"} local db = require("db.model").get("mrsang","subscribers",sample)