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 = encoding.encode_base64 encoding.hmac_sha1("ninjas", @params.password)
|
||||||
@params.password_again = nil
|
@params.password_again = nil
|
||||||
@params.csrf_token = nil
|
@params.csrf_token = nil
|
||||||
@params.extension = "9001"
|
@params.extension = "#{1000}"
|
||||||
@params.registrar_password = encoding.encode_base64 encoding.hmac_sha1(@params.email, os.time!)
|
@params.registrar_password = encoding.encode_base64 encoding.hmac_sha1(@params.email, os.time!)
|
||||||
|
|
||||||
if Users\find email: @params.email
|
if Users\find email: @params.email
|
||||||
|
@ -45,6 +45,8 @@ class App extends lapis.Application
|
||||||
|
|
||||||
user = Users\create @params
|
user = Users\create @params
|
||||||
user\write_session @
|
user\write_session @
|
||||||
|
user.extension = "#{1000 + user.id}"
|
||||||
|
Users\update user
|
||||||
|
|
||||||
@title = "Success"
|
@title = "Success"
|
||||||
|
|
||||||
|
@ -53,7 +55,7 @@ class App extends lapis.Application
|
||||||
p ->
|
p ->
|
||||||
text "Your email is " .. user.email
|
text "Your email is " .. user.email
|
||||||
p ->
|
p ->
|
||||||
text "Your extension is " .. user.id
|
text "Your extension is " .. user.extension
|
||||||
p ->
|
p ->
|
||||||
text "Your sip password is "
|
text "Your sip password is "
|
||||||
code user.registrar_password
|
code user.registrar_password
|
||||||
|
@ -93,6 +95,8 @@ class App extends lapis.Application
|
||||||
POST: =>
|
POST: =>
|
||||||
uid = @params["user"] or @params["sip_auth_username"]
|
uid = @params["user"] or @params["sip_auth_username"]
|
||||||
@user = Users\find id: uid
|
@user = Users\find id: uid
|
||||||
|
if not @user
|
||||||
|
return status: 404, "no such user"
|
||||||
|
|
||||||
render: true, layout: false
|
render: true, layout: false
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@ class Freeswitch extends Widget
|
||||||
groups ->
|
groups ->
|
||||||
group name: "default", ->
|
group name: "default", ->
|
||||||
users ->
|
users ->
|
||||||
user id: "#{@user.id}", ->
|
user id: "#{@user.extension}", ->
|
||||||
params ->
|
params ->
|
||||||
param name: "password", value: "#{@user.registrar_password}"
|
param name: "password", value: "#{@user.registrar_password}"
|
||||||
variables ->
|
variables ->
|
||||||
variable name: "accountcode", value: "#{@user.id}"
|
variable name: "accountcode", value: "#{@user.extension}"
|
||||||
variable name: "user_context", value: "default"
|
variable name: "user_context", value: "default"
|
||||||
|
|
Loading…
Reference in New Issue