Skip to content

Commit

Permalink
Add API endpoint for /setup
Browse files Browse the repository at this point in the history
  • Loading branch information
aw committed Jun 1, 2015
1 parent bbb186f commit b874f29
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
26 changes: 26 additions & 0 deletions api/v1/admin/setup/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2015 Alexander Williams, Unscramble <license@unscramble.jp>

(de setup-update ()
(if (get 'newtoken 'http)
(if (update-token @)
(http-msg 200)
(http-msg 400) )
(http-msg 400) ) )

[de setup-new ()
(let Path (pack *Admin_path "etc/api.token")
(if (num? (car (info Path)))
(http-msg 403)
(setup-update) ]

[de setup-request ()
(when *Post
(if (validate-token (get 'token 'http))
(setup-update)
(setup-new) ]

(setup-request)
2 changes: 1 addition & 1 deletion api/v1/core/allowed.l
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# Copyright (c) 2015 Alexander Williams, Unscramble <license@unscramble.jp>

(allowed ("api/v1/admin")
token license settings update )
newtoken token setup license settings update )
7 changes: 3 additions & 4 deletions api/v1/core/auth.l
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
(= Token (in Path (line T) ]

[de update-token (Token)
(let Path (pack *Admin_path "etc/api.token")
(unless (num? (car (info Path)))
(out (pack *Upload_path "api.token") (prinl Token))
(call 'sudo (pack *Admin_path "bin/update_token.sh") ]
(when Token
(out (pack *Upload_path "api.token") (prinl Token))
(call 'sudo (pack *Admin_path "bin/update_token.sh") ]

0 comments on commit b874f29

Please sign in to comment.