]> gitweb.factorcode.org Git - factor.git/blob - basis/furnace/auth/features/registration/registration.factor
Switch to https urls
[factor.git] / basis / furnace / auth / features / registration / registration.factor
1 ! Copyright (c) 2008 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs furnace.actions furnace.auth
4 furnace.auth.providers html.forms http.server.dispatchers kernel
5 namespaces validators ;
6 IN: furnace.auth.features.registration
7
8 : <register-action> ( -- action )
9     <page-action>
10         { realm "features/registration/register" } >>template
11
12         [
13             {
14                 { "username" [ v-username ] }
15                 { "realname" [ [ v-one-line ] v-optional ] }
16                 { "new-password" [ v-password ] }
17                 { "verify-password" [ v-password ] }
18                 { "email" [ [ v-email ] v-optional ] }
19                 { "captcha" [ v-captcha ] }
20             } validate-params
21
22             same-password-twice
23         ] >>validate
24
25         [
26             "username" value <user>
27                 "realname" value >>realname
28                 "new-password" value >>encoded-password
29                 "email" value >>email
30                 H{ } clone >>profile
31
32             users new-user [ user-exists ] unless*
33
34             realm get init-user-profile
35             realm get user-registered
36         ] >>submit
37     <auth-boilerplate>
38     <secure-realm-only> ;
39
40 : allow-registration ( realm -- realm )
41     <register-action> "register" add-responder ;
42
43 : allow-registration? ( -- ? )
44     realm get responders>> "register" swap key? ;