]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/CGI.pm
prevent users from registering with name that is not a valid wikifile
[git.ikiwiki.info.git] / IkiWiki / CGI.pm
index 1d642687bbefa7820257fce1dc9994ed42476959..067886c70d49c1eed93865b8f867584a73a06605 100644 (file)
@@ -118,6 +118,7 @@ sub cgi_signin ($$) { #{{{
                                validate => sub {
                                        my $name=shift;
                                        length $name &&
+                                       $name=~/$wiki_file_regexp/ &&
                                        ! userinfo_get($name, "regdate");
                                },
                        );
@@ -217,7 +218,8 @@ sub cgi_prefs ($$) { #{{{
        eval q{use CGI::FormBuilder};
        my $form = CGI::FormBuilder->new(
                title => "preferences",
-               fields => [qw(do name password confirm_password email locked_pages)],
+               fields => [qw(do name password confirm_password email 
+                             subscriptions locked_pages)],
                header => 0,
                method => 'POST',
                validate => {
@@ -242,6 +244,8 @@ sub cgi_prefs ($$) { #{{{
                value => $user_name, force => 1);
        $form->field(name => "password", type => "password");
        $form->field(name => "confirm_password", type => "password");
+       $form->field(name => "subscriptions", size => 50,
+               comment => "(".htmllink("", "GlobList", 1).")");
        $form->field(name => "locked_pages", size => 50,
                comment => "(".htmllink("", "GlobList", 1).")");
        
@@ -252,6 +256,8 @@ sub cgi_prefs ($$) { #{{{
        if (! $form->submitted) {
                $form->field(name => "email", force => 1,
                        value => userinfo_get($user_name, "email"));
+               $form->field(name => "subscriptions", force => 1,
+                       value => userinfo_get($user_name, "subscriptions"));
                $form->field(name => "locked_pages", force => 1,
                        value => userinfo_get($user_name, "locked_pages"));
        }
@@ -266,7 +272,7 @@ sub cgi_prefs ($$) { #{{{
                return;
        }
        elsif ($form->submitted eq "Save Preferences" && $form->validate) {
-               foreach my $field (qw(password email locked_pages)) {
+               foreach my $field (qw(password email subscriptions locked_pages)) {
                        if (length $form->field($field)) {
                                userinfo_set($user_name, $field, $form->field($field)) || error("failed to set $field");
                        }
@@ -373,7 +379,7 @@ sub cgi_editpage ($$) { #{{{
                        }
                        else {
                                my $dir=$from."/";
-                               $dir=~s![^/]+/$!!;
+                               $dir=~s![^/]+/+$!!;
                                
                                if ((defined $form->param('subpage') && length $form->param('subpage')) ||
                                    $page eq 'discussion') {
@@ -386,7 +392,7 @@ sub cgi_editpage ($$) { #{{{
                                push @page_locs, $dir.$page;
                                push @page_locs, "$from/$page";
                                while (length $dir) {
-                                       $dir=~s![^/]+/$!!;
+                                       $dir=~s![^/]+/+$!!;
                                        push @page_locs, $dir.$page;
                                }