Fossil SCM
Correct new-post for anonymous users. Remove the captcha support from the forum pieces - it was introduced inadvertently, is not part of trunk's forum, and supporting it for anonymous users with inline responses would require more surgery.
Commit
0896ceb7954df7f5024ea017bfb96c7bb3c7dc6d4b4aaeab2fea9a99484be723
Parent
d41bd6582127e3a…
3 files changed
-18
-6
+9
-10
-18
| --- src/captcha.c | ||
| +++ src/captcha.c | ||
| @@ -712,28 +712,10 @@ | ||
| 712 | 712 | } |
| 713 | 713 | @ <br/>\ |
| 714 | 714 | captcha_speakit_button(uSeed, 0); |
| 715 | 715 | @ </td></tr></table></div> |
| 716 | 716 | } |
| 717 | - | |
| 718 | -/* | |
| 719 | -** Like captcha_generate() but emits it in a different form, intended | |
| 720 | -** for consumption by JS. | |
| 721 | -*/ | |
| 722 | -void captcha_generate_for_js(int mFlags){ | |
| 723 | - unsigned int uSeed; | |
| 724 | - const char *zDecoded; | |
| 725 | - char *zCaptcha; | |
| 726 | - | |
| 727 | - if( !captcha_needed() && (mFlags & 0x02)==0 ) return; | |
| 728 | - uSeed = captcha_seed(); | |
| 729 | - zDecoded = captcha_decode(uSeed, 0); | |
| 730 | - zCaptcha = captcha_render(zDecoded); | |
| 731 | - @ <div class='hidden captcha-for-js'>%h(zCaptcha)</div> | |
| 732 | - @ <input type="hidden" name="captchaseed" value="%u(uSeed)"> | |
| 733 | -} | |
| 734 | - | |
| 735 | 717 | |
| 736 | 718 | /* |
| 737 | 719 | ** Add a "Speak the captcha" button. |
| 738 | 720 | */ |
| 739 | 721 | void captcha_speakit_button(unsigned int uSeed, const char *zMsg){ |
| 740 | 722 |
| --- src/captcha.c | |
| +++ src/captcha.c | |
| @@ -712,28 +712,10 @@ | |
| 712 | } |
| 713 | @ <br/>\ |
| 714 | captcha_speakit_button(uSeed, 0); |
| 715 | @ </td></tr></table></div> |
| 716 | } |
| 717 | |
| 718 | /* |
| 719 | ** Like captcha_generate() but emits it in a different form, intended |
| 720 | ** for consumption by JS. |
| 721 | */ |
| 722 | void captcha_generate_for_js(int mFlags){ |
| 723 | unsigned int uSeed; |
| 724 | const char *zDecoded; |
| 725 | char *zCaptcha; |
| 726 | |
| 727 | if( !captcha_needed() && (mFlags & 0x02)==0 ) return; |
| 728 | uSeed = captcha_seed(); |
| 729 | zDecoded = captcha_decode(uSeed, 0); |
| 730 | zCaptcha = captcha_render(zDecoded); |
| 731 | @ <div class='hidden captcha-for-js'>%h(zCaptcha)</div> |
| 732 | @ <input type="hidden" name="captchaseed" value="%u(uSeed)"> |
| 733 | } |
| 734 | |
| 735 | |
| 736 | /* |
| 737 | ** Add a "Speak the captcha" button. |
| 738 | */ |
| 739 | void captcha_speakit_button(unsigned int uSeed, const char *zMsg){ |
| 740 |
| --- src/captcha.c | |
| +++ src/captcha.c | |
| @@ -712,28 +712,10 @@ | |
| 712 | } |
| 713 | @ <br/>\ |
| 714 | captcha_speakit_button(uSeed, 0); |
| 715 | @ </td></tr></table></div> |
| 716 | } |
| 717 | |
| 718 | /* |
| 719 | ** Add a "Speak the captcha" button. |
| 720 | */ |
| 721 | void captcha_speakit_button(unsigned int uSeed, const char *zMsg){ |
| 722 |
-6
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -2047,11 +2047,10 @@ | ||
| 2047 | 2047 | When it's enabled, the above won't do anything and |
| 2048 | 2048 | JS will render the editor form in the next element. */ |
| 2049 | 2049 | @ <div hidden id='forumnew-placeholder'> |
| 2050 | 2050 | @ <input type='hidden' name='title' value='%h(zTitle)'> |
| 2051 | 2051 | login_insert_csrf_secret(); |
| 2052 | - captcha_generate_for_js(0); | |
| 2053 | 2052 | @ </div> |
| 2054 | 2053 | } |
| 2055 | 2054 | forum_emit_js(); |
| 2056 | 2055 | style_finish_page(); |
| 2057 | 2056 | } |
| @@ -2282,11 +2281,10 @@ | ||
| 2282 | 2281 | @ <div hidden id='forumedit-placeholder'> |
| 2283 | 2282 | #if 0 |
| 2284 | 2283 | @ <input type='hidden' name='title' value='%h(zTitle)'> |
| 2285 | 2284 | #endif |
| 2286 | 2285 | login_insert_csrf_secret(); |
| 2287 | - captcha_generate_for_js(0); | |
| 2288 | 2286 | @ </div> |
| 2289 | 2287 | forum_emit_js(); |
| 2290 | 2288 | style_finish_page(); |
| 2291 | 2289 | |
| 2292 | 2290 | } |
| @@ -2984,11 +2982,10 @@ | ||
| 2984 | 2982 | const char *zContent; |
| 2985 | 2983 | const char *zStatus; |
| 2986 | 2984 | const int bHasAttachment = P("file1")!=0; |
| 2987 | 2985 | Manifest *pPost = 0; |
| 2988 | 2986 | char *zNewUuid = 0; |
| 2989 | - int goodCaptcha = 1; | |
| 2990 | 2987 | int firt = 0; /* In-reply-to rid or 0 */ |
| 2991 | 2988 | int fpid = 0; /* Post rid being edited or 0 */ |
| 2992 | 2989 | int rc = 0; /* Result code. */ |
| 2993 | 2990 | int nrid = 0; /* New artifact rid. */ |
| 2994 | 2991 | int iPostFlags; /* forum_post_flags() (after perms check) */ |
| @@ -3001,13 +2998,10 @@ | ||
| 3001 | 2998 | ajax_route_error_forbidden(); |
| 3002 | 2999 | return; |
| 3003 | 3000 | }else if( !ajax_check_csrf(2) ){ |
| 3004 | 3001 | ajax_route_error_csrf(); |
| 3005 | 3002 | return; |
| 3006 | - }else if( 0==(goodCaptcha = captcha_is_correct(0)) ){ | |
| 3007 | - ajax_route_error_captcha(); | |
| 3008 | - return; | |
| 3009 | 3003 | } |
| 3010 | 3004 | |
| 3011 | 3005 | iPostFlags = forum_post_flags(/*must come after permissions init*/); |
| 3012 | 3006 | bRollback = (FPOST_DRYRUN & iPostFlags); |
| 3013 | 3007 | zFpid = P("fpid"); |
| 3014 | 3008 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -2047,11 +2047,10 @@ | |
| 2047 | When it's enabled, the above won't do anything and |
| 2048 | JS will render the editor form in the next element. */ |
| 2049 | @ <div hidden id='forumnew-placeholder'> |
| 2050 | @ <input type='hidden' name='title' value='%h(zTitle)'> |
| 2051 | login_insert_csrf_secret(); |
| 2052 | captcha_generate_for_js(0); |
| 2053 | @ </div> |
| 2054 | } |
| 2055 | forum_emit_js(); |
| 2056 | style_finish_page(); |
| 2057 | } |
| @@ -2282,11 +2281,10 @@ | |
| 2282 | @ <div hidden id='forumedit-placeholder'> |
| 2283 | #if 0 |
| 2284 | @ <input type='hidden' name='title' value='%h(zTitle)'> |
| 2285 | #endif |
| 2286 | login_insert_csrf_secret(); |
| 2287 | captcha_generate_for_js(0); |
| 2288 | @ </div> |
| 2289 | forum_emit_js(); |
| 2290 | style_finish_page(); |
| 2291 | |
| 2292 | } |
| @@ -2984,11 +2982,10 @@ | |
| 2984 | const char *zContent; |
| 2985 | const char *zStatus; |
| 2986 | const int bHasAttachment = P("file1")!=0; |
| 2987 | Manifest *pPost = 0; |
| 2988 | char *zNewUuid = 0; |
| 2989 | int goodCaptcha = 1; |
| 2990 | int firt = 0; /* In-reply-to rid or 0 */ |
| 2991 | int fpid = 0; /* Post rid being edited or 0 */ |
| 2992 | int rc = 0; /* Result code. */ |
| 2993 | int nrid = 0; /* New artifact rid. */ |
| 2994 | int iPostFlags; /* forum_post_flags() (after perms check) */ |
| @@ -3001,13 +2998,10 @@ | |
| 3001 | ajax_route_error_forbidden(); |
| 3002 | return; |
| 3003 | }else if( !ajax_check_csrf(2) ){ |
| 3004 | ajax_route_error_csrf(); |
| 3005 | return; |
| 3006 | }else if( 0==(goodCaptcha = captcha_is_correct(0)) ){ |
| 3007 | ajax_route_error_captcha(); |
| 3008 | return; |
| 3009 | } |
| 3010 | |
| 3011 | iPostFlags = forum_post_flags(/*must come after permissions init*/); |
| 3012 | bRollback = (FPOST_DRYRUN & iPostFlags); |
| 3013 | zFpid = P("fpid"); |
| 3014 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -2047,11 +2047,10 @@ | |
| 2047 | When it's enabled, the above won't do anything and |
| 2048 | JS will render the editor form in the next element. */ |
| 2049 | @ <div hidden id='forumnew-placeholder'> |
| 2050 | @ <input type='hidden' name='title' value='%h(zTitle)'> |
| 2051 | login_insert_csrf_secret(); |
| 2052 | @ </div> |
| 2053 | } |
| 2054 | forum_emit_js(); |
| 2055 | style_finish_page(); |
| 2056 | } |
| @@ -2282,11 +2281,10 @@ | |
| 2281 | @ <div hidden id='forumedit-placeholder'> |
| 2282 | #if 0 |
| 2283 | @ <input type='hidden' name='title' value='%h(zTitle)'> |
| 2284 | #endif |
| 2285 | login_insert_csrf_secret(); |
| 2286 | @ </div> |
| 2287 | forum_emit_js(); |
| 2288 | style_finish_page(); |
| 2289 | |
| 2290 | } |
| @@ -2984,11 +2982,10 @@ | |
| 2982 | const char *zContent; |
| 2983 | const char *zStatus; |
| 2984 | const int bHasAttachment = P("file1")!=0; |
| 2985 | Manifest *pPost = 0; |
| 2986 | char *zNewUuid = 0; |
| 2987 | int firt = 0; /* In-reply-to rid or 0 */ |
| 2988 | int fpid = 0; /* Post rid being edited or 0 */ |
| 2989 | int rc = 0; /* Result code. */ |
| 2990 | int nrid = 0; /* New artifact rid. */ |
| 2991 | int iPostFlags; /* forum_post_flags() (after perms check) */ |
| @@ -3001,13 +2998,10 @@ | |
| 2998 | ajax_route_error_forbidden(); |
| 2999 | return; |
| 3000 | }else if( !ajax_check_csrf(2) ){ |
| 3001 | ajax_route_error_csrf(); |
| 3002 | return; |
| 3003 | } |
| 3004 | |
| 3005 | iPostFlags = forum_post_flags(/*must come after permissions init*/); |
| 3006 | bRollback = (FPOST_DRYRUN & iPostFlags); |
| 3007 | zFpid = P("fpid"); |
| 3008 |
+9
-10
| --- src/fossil.page.forumpost.js | ||
| +++ src/fossil.page.forumpost.js | ||
| @@ -875,36 +875,35 @@ | ||
| 875 | 875 | }); |
| 876 | 876 | }); |
| 877 | 877 | }); |
| 878 | 878 | } |
| 879 | 879 | |
| 880 | - F.user.isIndividual = ['anonymous','guest'].indexOf(F.user.name)<0; | |
| 880 | + F.user.isIndividual = ['anonymous','nobody'].indexOf(F.user.name)<0; | |
| 881 | 881 | |
| 882 | - const eForumNew = document.body.classList.contains('cpage-forumnew') | |
| 882 | + const eForumNew = ( | |
| 883 | + document.body.classList.contains('cpage-forumnew') | |
| 884 | + || document.body.classList.contains('cpage-forume1') | |
| 885 | + ) | |
| 883 | 886 | ? document.querySelector('#forumnew-placeholder') |
| 884 | 887 | : null; |
| 885 | 888 | if( eForumNew ){ |
| 886 | - /* /forumnew */ | |
| 889 | + /* /forumnew and /forume2 */ | |
| 887 | 890 | const fpe = new F.ForumPostEditor({ |
| 888 | 891 | draftKey: 'draft-forumnew', |
| 889 | 892 | hiddenFields: eForumNew.querySelectorAll('input[type=hidden]'), |
| 890 | - captcha: eForumNew.querySelector('.captcha-for-js'), | |
| 891 | 893 | ondiscard: ()=>{ |
| 892 | 894 | window.location = F.repoUrl('forum'); |
| 893 | 895 | } |
| 894 | 896 | }); |
| 895 | 897 | eForumNew.parentElement.insertBefore(fpe.widget, eForumNew); |
| 896 | 898 | eForumNew.remove(); |
| 897 | 899 | fossil.page.fpe = fpe /* for testing via the console */; |
| 898 | 900 | }/*eForumNew*/ |
| 899 | - else if( F.user.isIndividual | |
| 900 | - && (document.body.classList.contains('cpage-forumpost') | |
| 901 | - || document.body.classList.contains('cpage-forumthread'))){ | |
| 901 | + else if( (document.body.classList.contains('cpage-forumpost') | |
| 902 | + || document.body.classList.contains('cpage-forumthread'))){ | |
| 902 | 903 | /* /forumpost and /forumthread. Take over the Edit/Reply buttons |
| 903 | - to use a ForumPostEditor. Because of complications involving | |
| 904 | - fetching a captcha, we'll leave the buttons as-is for | |
| 905 | - non-logged-in users. */ | |
| 904 | + to use a ForumPostEditor. */ | |
| 906 | 905 | |
| 907 | 906 | const fetchPost = async (fpid)=>{ |
| 908 | 907 | return window.fetch(F.repoUrl('ajax/artifact.json?uuid='+fpid)) |
| 909 | 908 | .then(r=>r.json()) |
| 910 | 909 | .then(j=>{ |
| 911 | 910 |
| --- src/fossil.page.forumpost.js | |
| +++ src/fossil.page.forumpost.js | |
| @@ -875,36 +875,35 @@ | |
| 875 | }); |
| 876 | }); |
| 877 | }); |
| 878 | } |
| 879 | |
| 880 | F.user.isIndividual = ['anonymous','guest'].indexOf(F.user.name)<0; |
| 881 | |
| 882 | const eForumNew = document.body.classList.contains('cpage-forumnew') |
| 883 | ? document.querySelector('#forumnew-placeholder') |
| 884 | : null; |
| 885 | if( eForumNew ){ |
| 886 | /* /forumnew */ |
| 887 | const fpe = new F.ForumPostEditor({ |
| 888 | draftKey: 'draft-forumnew', |
| 889 | hiddenFields: eForumNew.querySelectorAll('input[type=hidden]'), |
| 890 | captcha: eForumNew.querySelector('.captcha-for-js'), |
| 891 | ondiscard: ()=>{ |
| 892 | window.location = F.repoUrl('forum'); |
| 893 | } |
| 894 | }); |
| 895 | eForumNew.parentElement.insertBefore(fpe.widget, eForumNew); |
| 896 | eForumNew.remove(); |
| 897 | fossil.page.fpe = fpe /* for testing via the console */; |
| 898 | }/*eForumNew*/ |
| 899 | else if( F.user.isIndividual |
| 900 | && (document.body.classList.contains('cpage-forumpost') |
| 901 | || document.body.classList.contains('cpage-forumthread'))){ |
| 902 | /* /forumpost and /forumthread. Take over the Edit/Reply buttons |
| 903 | to use a ForumPostEditor. Because of complications involving |
| 904 | fetching a captcha, we'll leave the buttons as-is for |
| 905 | non-logged-in users. */ |
| 906 | |
| 907 | const fetchPost = async (fpid)=>{ |
| 908 | return window.fetch(F.repoUrl('ajax/artifact.json?uuid='+fpid)) |
| 909 | .then(r=>r.json()) |
| 910 | .then(j=>{ |
| 911 |
| --- src/fossil.page.forumpost.js | |
| +++ src/fossil.page.forumpost.js | |
| @@ -875,36 +875,35 @@ | |
| 875 | }); |
| 876 | }); |
| 877 | }); |
| 878 | } |
| 879 | |
| 880 | F.user.isIndividual = ['anonymous','nobody'].indexOf(F.user.name)<0; |
| 881 | |
| 882 | const eForumNew = ( |
| 883 | document.body.classList.contains('cpage-forumnew') |
| 884 | || document.body.classList.contains('cpage-forume1') |
| 885 | ) |
| 886 | ? document.querySelector('#forumnew-placeholder') |
| 887 | : null; |
| 888 | if( eForumNew ){ |
| 889 | /* /forumnew and /forume2 */ |
| 890 | const fpe = new F.ForumPostEditor({ |
| 891 | draftKey: 'draft-forumnew', |
| 892 | hiddenFields: eForumNew.querySelectorAll('input[type=hidden]'), |
| 893 | ondiscard: ()=>{ |
| 894 | window.location = F.repoUrl('forum'); |
| 895 | } |
| 896 | }); |
| 897 | eForumNew.parentElement.insertBefore(fpe.widget, eForumNew); |
| 898 | eForumNew.remove(); |
| 899 | fossil.page.fpe = fpe /* for testing via the console */; |
| 900 | }/*eForumNew*/ |
| 901 | else if( (document.body.classList.contains('cpage-forumpost') |
| 902 | || document.body.classList.contains('cpage-forumthread'))){ |
| 903 | /* /forumpost and /forumthread. Take over the Edit/Reply buttons |
| 904 | to use a ForumPostEditor. */ |
| 905 | |
| 906 | const fetchPost = async (fpid)=>{ |
| 907 | return window.fetch(F.repoUrl('ajax/artifact.json?uuid='+fpid)) |
| 908 | .then(r=>r.json()) |
| 909 | .then(j=>{ |
| 910 |