panel/controllers/freeswitch.moon

23 lines
599 B
Plaintext
Raw Normal View History

lapis = require "lapis"
import respond_to from require "lapis.application"
2015-01-07 22:35:38 +00:00
require "models.token"
require "models.user"
class Freeswitch extends lapis.Application
[freeswitch: "/freeswitch"]: respond_to {
POST: =>
uid = @params["user"] or @params["sip_auth_username"]
@user = Users\find extension: uid
2015-01-07 22:35:38 +00:00
@tokens = Tokens\select "where user_id = ?", uid
if #@tokens == 0
return status: 404, layout: false, "no auth tokens for " .. uid
if not @user
2015-01-07 22:35:38 +00:00
return status: 404, layout: false, "no such user " .. uid
render: true, layout: false
}