controllers/freeswitch: reorder the failure logic for no such user

This commit is contained in:
Sam Dodrill 2015-01-07 16:44:55 -08:00
parent 2b05ef2c96
commit 70c130d978
1 changed files with 4 additions and 3 deletions

View File

@ -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
}