mirror of
https://github.com/urbit/shrub.git
synced 2024-12-16 23:04:16 +03:00
Extract a generic +require-authorization gate.
This commit is contained in:
parent
5d12ae900a
commit
8d87a2ca22
@ -121,6 +121,23 @@
|
||||
::
|
||||
"</body></html>"
|
||||
==
|
||||
:: +require-authorization: redirect to the login page when unauthenticated
|
||||
::
|
||||
++ require-authorization
|
||||
|* [=bone move=mold this=*]
|
||||
|= handler=$-(inbound-request:light (quip move _this))
|
||||
|= =inbound-request:light
|
||||
^- (quip move _this)
|
||||
::
|
||||
?: authenticated.inbound-request
|
||||
(handler inbound-request)
|
||||
::
|
||||
:_ this
|
||||
^- (list move)
|
||||
=/ redirect=cord
|
||||
%- crip
|
||||
"/~/login?redirect={(trip url.http-request.inbound-request)}"
|
||||
[bone [%http-response %start 307 ['location' redirect]~ ~ %.y]]~
|
||||
--
|
||||
|%
|
||||
::
|
||||
@ -179,29 +196,13 @@
|
||||
:- ^- move
|
||||
[ost.bow %wait /timer (add now.bow ~s1)]
|
||||
moves
|
||||
::
|
||||
:: ++ require-authorization
|
||||
:: |= handle=$-(inbound-request:light (quip move _this))
|
||||
:: |= =inbound-request:light
|
||||
:: ^- (quip move _this)
|
||||
:: ::
|
||||
:: ::
|
||||
:: (handle inbound-request)
|
||||
|
||||
:: +poke-handle-http-request: received on a new connection established
|
||||
::
|
||||
++ poke-handle-http-request
|
||||
%- (require-authorization ost.bow move this)
|
||||
|= =inbound-request:light
|
||||
^- (quip move _this)
|
||||
::
|
||||
?. authenticated.inbound-request
|
||||
:_ this
|
||||
^- (list move)
|
||||
=/ redirect=cord
|
||||
%- crip
|
||||
"/~/login?redirect={(trip url.http-request.inbound-request)}"
|
||||
[ost.bow [%http-response %start 307 ['location' redirect]~ ~ %.y]]~
|
||||
::
|
||||
=+ request-line=(parse-request-line url.http-request.inbound-request)
|
||||
~& [%request-line request-line]
|
||||
=/ name=@t
|
||||
|
Loading…
Reference in New Issue
Block a user