Debugging furnace.auth refactoring
parent
65b8e375df
commit
73105cc043
|
@ -17,6 +17,8 @@ IN: furnace.auth
|
|||
|
||||
SYMBOL: logged-in-user
|
||||
|
||||
: logged-in? ( -- ? ) logged-in-user get >boolean ;
|
||||
|
||||
GENERIC: init-user-profile ( responder -- )
|
||||
|
||||
M: object init-user-profile drop ;
|
||||
|
@ -114,7 +116,7 @@ TUPLE: protected < filter-responder description capabilities ;
|
|||
: check-capabilities ( responder user/f -- ? )
|
||||
{
|
||||
{ [ dup not ] [ 2drop f ] }
|
||||
{ [ dup deleted>> ] [ 2drop f ] }
|
||||
{ [ dup deleted>> 1 = ] [ 2drop f ] }
|
||||
[ [ capabilities>> ] bi@ subset? ]
|
||||
} cond ;
|
||||
|
||||
|
|
|
@ -64,4 +64,4 @@ IN: furnace.auth.features.edit-profile
|
|||
<edit-profile-action> <auth-boilerplate> "edit-profile" add-responder ;
|
||||
|
||||
: allow-edit-profile? ( -- ? )
|
||||
realm get get responders>> "edit-profile" swap key? ;
|
||||
realm get responders>> "edit-profile" swap key? ;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<t:title>Edit Profile</t:title>
|
||||
|
||||
<t:form t:action="$login/edit-profile">
|
||||
<t:form t:action="$realm/edit-profile">
|
||||
|
||||
<table>
|
||||
|
||||
|
|
|
@ -13,13 +13,16 @@ IN: furnace.auth.login
|
|||
|
||||
TUPLE: login-realm < realm ;
|
||||
|
||||
M: login-realm logged-in-username
|
||||
drop session get uid>> ;
|
||||
|
||||
: set-uid ( username -- )
|
||||
session get [ (>>uid) ] [ (session-changed) ] bi ;
|
||||
|
||||
: successful-login ( user -- response )
|
||||
username>> set-uid URL" $realm" end-aside ;
|
||||
|
||||
: logout ( -- ) f set-uid ;
|
||||
: logout ( -- ) f set-uid URL" $realm" end-aside ;
|
||||
|
||||
SYMBOL: description
|
||||
SYMBOL: capabilities
|
||||
|
@ -53,17 +56,14 @@ SYMBOL: capabilities
|
|||
|
||||
: <logout-action> ( -- action )
|
||||
<action>
|
||||
[ logout URL" $login-realm" end-aside ] >>submit ;
|
||||
[ logout ] >>submit ;
|
||||
|
||||
M: login-realm login-required*
|
||||
drop
|
||||
begin-aside
|
||||
protected get description>> description set
|
||||
protected get capabilities>> capabilities set
|
||||
URL" $login/login" flashed-variables <flash-redirect> ;
|
||||
|
||||
M: login-realm logged-in-username
|
||||
drop session get uid>> ;
|
||||
URL" $realm/login" flashed-variables <flash-redirect> ;
|
||||
|
||||
: <login-realm> ( responder name -- auth )
|
||||
login-realm new-realm
|
||||
|
|
|
@ -43,11 +43,11 @@
|
|||
</t:form>
|
||||
|
||||
<p>
|
||||
<t:if t:code="furnace.auth.login:allow-registration?">
|
||||
<t:if t:code="furnace.auth.features.registration:allow-registration?">
|
||||
<t:a t:href="register">Register</t:a>
|
||||
</t:if>
|
||||
|
|
||||
<t:if t:code="furnace.auth.login:allow-password-recovery?">
|
||||
<t:if t:code="furnace.auth.features.recover-password:allow-password-recovery?">
|
||||
<t:a t:href="recover-password">Recover Password</t:a>
|
||||
</t:if>
|
||||
</p>
|
||||
|
|
|
@ -31,7 +31,7 @@ IN: furnace
|
|||
|
||||
: base-path ( string -- pair )
|
||||
dup responder-nesting get
|
||||
[ second class word-name = ] with find nip
|
||||
[ second class superclasses [ word-name = ] with contains? ] with find nip
|
||||
[ first ] [ "No such responder: " swap append throw ] ?if ;
|
||||
|
||||
: resolve-base-path ( string -- string' )
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
| <t:a t:href="$blogs/by">My Posts</t:a>
|
||||
| <t:a t:href="$blogs/new-post">New Post</t:a>
|
||||
|
||||
<t:if t:code="furnace.sessions:uid">
|
||||
<t:if t:code="furnace.auth:logged-in?">
|
||||
|
||||
<t:if t:code="furnace.auth.login:allow-edit-profile?">
|
||||
| <t:a t:href="$login/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
<t:if t:code="furnace.auth.features.edit-profile:allow-edit-profile?">
|
||||
| <t:a t:href="$realm/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
</t:if>
|
||||
|
||||
| <t:button t:action="$login/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
| <t:button t:action="$login-realm/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
|
||||
</t:if>
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
<t:a t:href="$pastebin/list">Pastes</t:a>
|
||||
| <t:a t:href="$pastebin/new-paste">New Paste</t:a>
|
||||
|
||||
<t:if t:code="furnace.sessions:uid">
|
||||
<t:if t:code="furnace.auth:logged-in?">
|
||||
|
||||
<t:if t:code="furnace.auth.login:allow-edit-profile?">
|
||||
| <t:a t:href="$login/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
<t:if t:code="furnace.auth.features.edit-profile:allow-edit-profile?">
|
||||
| <t:a t:href="$realm/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
</t:if>
|
||||
|
||||
| <t:button t:action="$login/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
| <t:button t:action="$login-realm/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
|
||||
</t:if>
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
| <t:a t:href="$planet-factor/feed.xml">Atom Feed</t:a>
|
||||
| <t:a t:href="$planet-factor/admin">Admin</t:a>
|
||||
|
||||
<t:if t:code="furnace.sessions:uid">
|
||||
<t:if t:code="furnace.auth.login:allow-edit-profile?">
|
||||
| <t:a t:href="$login/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
<t:if t:code="furnace.auth:logged-in?">
|
||||
<t:if t:code="furnace.auth.features.edit-profile:allow-edit-profile?">
|
||||
| <t:a t:href="$realm/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
</t:if>
|
||||
|
||||
| <t:button t:action="$login/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
| <t:button t:action="$login-realm/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
</t:if>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
<t:a t:href="$todo-list/list">List Items</t:a>
|
||||
| <t:a t:href="$todo-list/new">Add Item</t:a>
|
||||
|
||||
<t:if t:code="furnace.auth.login:allow-edit-profile?">
|
||||
| <t:a t:href="$login/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
<t:if t:code="furnace.auth.features.edit-profile:allow-edit-profile?">
|
||||
| <t:a t:href="$realm/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
</t:if>
|
||||
|
||||
| <t:button t:action="$login/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
| <t:button t:action="$login-realm/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
</div>
|
||||
|
||||
<h1><t:write-title /></h1>
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
<t:a t:href="$user-admin">List Users</t:a>
|
||||
| <t:a t:href="$user-admin/new">Add User</t:a>
|
||||
|
||||
<t:if t:code="furnace.auth.login:allow-edit-profile?">
|
||||
| <t:a t:href="$login/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
<t:if t:code="furnace.auth.features.edit-profile:allow-edit-profile?">
|
||||
| <t:a t:href="$realm/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
</t:if>
|
||||
|
||||
| <t:button t:action="$login/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
| <t:button t:action="$login-realm/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
</div>
|
||||
|
||||
<h1><t:write-title /></h1>
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
| <t:a t:href="$wiki/articles">All Articles</t:a>
|
||||
| <t:a t:href="$wiki/changes">Recent Changes</t:a>
|
||||
|
||||
<t:if t:code="furnace.sessions:uid">
|
||||
<t:if t:code="furnace.auth:logged-in?">
|
||||
|
||||
<t:if t:code="furnace.auth.login:allow-edit-profile?">
|
||||
| <t:a t:href="$login/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
<t:if t:code="furnace.auth.features.edit-profile:allow-edit-profile?">
|
||||
| <t:a t:href="$realm/edit-profile" t:aside="begin">Edit Profile</t:a>
|
||||
</t:if>
|
||||
|
||||
| <t:button t:action="$login/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
| <t:button t:action="$login-realm/logout" t:aside="begin" class="link-button link">Logout</t:button>
|
||||
|
||||
</t:if>
|
||||
|
||||
|
|
Loading…
Reference in New Issue