factor/basis/furnace/auth/features/registration/registration.factor

46 lines
1.4 KiB
Factor
Raw Permalink Normal View History

2008-06-16 04:34:17 -04:00
! Copyright (c) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs kernel namespaces validators html.forms urls
http.server.dispatchers
2008-11-24 21:26:11 -05:00
furnace.auth furnace.auth.providers furnace.actions
2008-06-17 01:10:46 -04:00
furnace.redirection ;
2008-06-16 04:34:17 -04:00
IN: furnace.auth.features.registration
: <register-action> ( -- action )
<page-action>
{ realm "features/registration/register" } >>template
2008-06-16 04:34:17 -04:00
[
{
{ "username" [ v-username ] }
{ "realname" [ [ v-one-line ] v-optional ] }
{ "new-password" [ v-password ] }
{ "verify-password" [ v-password ] }
{ "email" [ [ v-email ] v-optional ] }
{ "captcha" [ v-captcha ] }
} validate-params
same-password-twice
] >>validate
[
"username" value <user>
"realname" value >>realname
"new-password" value >>encoded-password
"email" value >>email
H{ } clone >>profile
users new-user [ user-exists ] unless*
realm get init-user-profile
2008-09-22 17:09:20 -04:00
realm get user-registered
2008-06-18 04:26:50 -04:00
] >>submit
<auth-boilerplate>
<secure-realm-only> ;
2008-06-16 04:34:17 -04:00
2008-11-16 08:41:27 -05:00
: allow-registration ( realm -- realm )
2008-06-18 04:26:50 -04:00
<register-action> "register" add-responder ;
2008-06-16 04:34:17 -04:00
: allow-registration? ( -- ? )
realm get responders>> "register" swap key? ;