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)