From 70c130d9781fcf3e59b65402a894b96632a8c296 Mon Sep 17 00:00:00 2001 From: Sam Dodrill Date: Wed, 7 Jan 2015 16:44:55 -0800 Subject: [PATCH] controllers/freeswitch: reorder the failure logic for no such user --- controllers/freeswitch.moon | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/controllers/freeswitch.moon b/controllers/freeswitch.moon index 6247d91..78bd1a3 100644 --- a/controllers/freeswitch.moon +++ b/controllers/freeswitch.moon @@ -10,13 +10,14 @@ class Freeswitch extends lapis.Application POST: => uid = @params["user"] or @params["sip_auth_username"] @user = Users\find extension: uid + + if not @user + return status: 404, layout: false, "no such user " .. uid + @tokens = Tokens\select "where user_id = ?", uid if #@tokens == 0 return status: 404, layout: false, "no auth tokens for " .. uid - if not @user - return status: 404, layout: false, "no such user " .. uid - render: true, layout: false }