diff --git a/app.moon b/app.moon index 9ceb677..ead4215 100644 --- a/app.moon +++ b/app.moon @@ -36,7 +36,7 @@ class App extends lapis.Application @params.password = encoding.encode_base64 encoding.hmac_sha1("ninjas", @params.password) @params.password_again = nil @params.csrf_token = nil - @params.extension = "9001" + @params.extension = "#{1000}" @params.registrar_password = encoding.encode_base64 encoding.hmac_sha1(@params.email, os.time!) if Users\find email: @params.email @@ -45,6 +45,8 @@ class App extends lapis.Application user = Users\create @params user\write_session @ + user.extension = "#{1000 + user.id}" + Users\update user @title = "Success" @@ -53,7 +55,7 @@ class App extends lapis.Application p -> text "Your email is " .. user.email p -> - text "Your extension is " .. user.id + text "Your extension is " .. user.extension p -> text "Your sip password is " code user.registrar_password @@ -93,6 +95,8 @@ class App extends lapis.Application POST: => uid = @params["user"] or @params["sip_auth_username"] @user = Users\find id: uid + if not @user + return status: 404, "no such user" render: true, layout: false } diff --git a/views/freeswitch.moon b/views/freeswitch.moon index 6828c35..31c453c 100644 --- a/views/freeswitch.moon +++ b/views/freeswitch.moon @@ -10,9 +10,9 @@ class Freeswitch extends Widget groups -> group name: "default", -> users -> - user id: "#{@user.id}", -> + user id: "#{@user.extension}", -> params -> param name: "password", value: "#{@user.registrar_password}" variables -> - variable name: "accountcode", value: "#{@user.id}" + variable name: "accountcode", value: "#{@user.extension}" variable name: "user_context", value: "default"