app: make the extension the user's ID + 1000
This commit is contained in:
parent
b03bd4b7c4
commit
af83d44a29
8
app.moon
8
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
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue