From 3d77c75c38f57de611aded1b664b2571530a9bd8 Mon Sep 17 00:00:00 2001 From: tevko Date: Tue, 19 Nov 2024 19:20:01 -0600 Subject: [PATCH 1/3] disable non functional social auth --- .../js/templates/comment-form.handlebars | 38 -------- .../js/templates/vote-view.handlebars | 41 -------- server/src/server.ts | 96 +++++++------------ server/src/utils/constants.ts | 6 +- 4 files changed, 39 insertions(+), 142 deletions(-) diff --git a/client-participation/js/templates/comment-form.handlebars b/client-participation/js/templates/comment-form.handlebars index 3b7c3c8b65..282f40ca6a 100644 --- a/client-participation/js/templates/comment-form.handlebars +++ b/client-participation/js/templates/comment-form.handlebars @@ -152,44 +152,6 @@ - {{!-- ================ CONNECT FACEBOOK / TWITTER ================ --}} -
-

  {{s.connectToPostPrompt}}

- {{#if auth_opt_fb}} - {{#unless hasFacebook}} - - {{/unless}} - {{/if}} - {{#if auth_opt_tw}} - {{#unless hasTwitter}} - - {{/unless}} - {{/if}} -
- {{!-- ================ LOWER CONTAINER ================ --}}
-{{#if needSocial}} -{{!-- ================ CONNECT FACEBOOK / TWITTER ================ --}} -
-

  {{s.connectToVotePrompt}}

- {{#if auth_opt_fb}} - {{#unless hasFacebook}} - - {{/unless}} - {{/if}} - {{#if auth_opt_tw}} - {{#unless hasTwitter}} - - {{/unless}} - {{/if}} -
- -{{else}} {{!-- !needSocial --}} - {{#if empty}}
{{!-- empty scenario div --}} {{#if subscribed}} diff --git a/server/src/server.ts b/server/src/server.ts index 560487e9cc..4df1c6fd94 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -663,32 +663,32 @@ function initializePolisHelpers() { if (!conv.is_active) { throw "polis_err_conversation_is_closed"; } - if (conv.auth_needed_to_vote) { - return isModerator(zid, uid).then((is_mod: any) => { - if (is_mod) { - return conv; - } - return Promise.all([ - pgQueryP( - "select * from xids where owner = ($1) and uid = ($2);", - [conv.owner, uid] - ), - getSocialInfoForUsers([uid], zid), - // Binding elements 'xids' and 'info' implicitly have an 'any' type.ts(7031) - // @ts-ignore - ]).then(([xids, info]) => { - var socialAccountIsLinked = info.length > 0; - // Object is of type 'unknown'.ts(2571) - // @ts-ignore - var hasXid = xids.length > 0; - if (socialAccountIsLinked || hasXid) { - return conv; - } else { - throw "polis_err_post_votes_social_needed"; - } - }); - }); - } + // if (conv.auth_needed_to_vote) { + // return isModerator(zid, uid).then((is_mod: any) => { + // if (is_mod) { + // return conv; + // } + // return Promise.all([ + // pgQueryP( + // "select * from xids where owner = ($1) and uid = ($2);", + // [conv.owner, uid] + // ), + // getSocialInfoForUsers([uid], zid), + // // Binding elements 'xids' and 'info' implicitly have an 'any' type.ts(7031) + // // @ts-ignore + // ]).then(([xids, info]) => { + // var socialAccountIsLinked = info.length > 0; + // // Object is of type 'unknown'.ts(2571) + // // @ts-ignore + // var hasXid = xids.length > 0; + // if (socialAccountIsLinked || hasXid) { + // return conv; + // } else { + // throw "polis_err_post_votes_social_needed"; + // } + // }); + // }); + // } if (conv.use_xid_whitelist) { return isXidWhitelisted(conv.owner, xid).then( (is_whitelisted: boolean) => { @@ -8125,10 +8125,6 @@ Email verified! You can close this tab or hit the back button. if (!_.isUndefined(req.p.write_type)) { fields.write_type = req.p.write_type; } - ifDefinedSet("auth_needed_to_vote", req.p, fields); - ifDefinedSet("auth_needed_to_write", req.p, fields); - ifDefinedSet("auth_opt_fb", req.p, fields); - ifDefinedSet("auth_opt_tw", req.p, fields); ifDefinedSet("auth_opt_allow_3rdparty", req.p, fields); if (!_.isUndefined(req.p.owner_sees_participation_stats)) { @@ -8840,12 +8836,8 @@ Email verified! You can close this tab or hit the back button. conv.auth_opt_allow_3rdparty, true ); - conv.auth_opt_fb_computed = - conv.auth_opt_allow_3rdparty && - ifDefinedFirstElseSecond(conv.auth_opt_fb, true); - conv.auth_opt_tw_computed = - conv.auth_opt_allow_3rdparty && - ifDefinedFirstElseSecond(conv.auth_opt_tw, true); + conv.auth_opt_fb_computed = false; + conv.auth_opt_tw_computed = false; conv.translations = translations; @@ -9562,15 +9554,13 @@ Email verified! You can close this tab or hit the back button. owner_sees_participation_stats: !!req.p .owner_sees_participation_stats, // Set defaults for fields that aren't set at postgres level. - auth_needed_to_vote: - req.p.auth_needed_to_vote || DEFAULTS.auth_needed_to_vote, - auth_needed_to_write: - req.p.auth_needed_to_write || DEFAULTS.auth_needed_to_write, + auth_needed_to_vote: DEFAULTS.auth_needed_to_vote, + auth_needed_to_write: DEFAULTS.auth_needed_to_write, auth_opt_allow_3rdparty: req.p.auth_opt_allow_3rdparty || DEFAULTS.auth_opt_allow_3rdparty, - auth_opt_fb: req.p.auth_opt_fb || DEFAULTS.auth_opt_fb, - auth_opt_tw: req.p.auth_opt_tw || DEFAULTS.auth_opt_tw, + auth_opt_fb: DEFAULTS.auth_opt_fb, + auth_opt_tw: DEFAULTS.auth_opt_tw, }) .returning("*") .toString(); @@ -12469,12 +12459,8 @@ Thanks for using Polis! conv.auth_opt_allow_3rdparty, DEFAULTS.auth_opt_allow_3rdparty ); - let auth_opt_fb_computed = - auth_opt_allow_3rdparty && - ifDefinedFirstElseSecond(conv.auth_opt_fb, DEFAULTS.auth_opt_fb); - let auth_opt_tw_computed = - auth_opt_allow_3rdparty && - ifDefinedFirstElseSecond(conv.auth_opt_tw, DEFAULTS.auth_opt_tw); + let auth_opt_fb_computed = false; + let auth_opt_tw_computed = false; conv = { topic: conv.topic, @@ -12490,14 +12476,8 @@ Thanks for using Polis! help_color: conv.help_color, help_bgcolor: conv.help_bgcolor, style_btn: conv.style_btn, - auth_needed_to_vote: ifDefinedFirstElseSecond( - conv.auth_needed_to_vote, - DEFAULTS.auth_needed_to_vote - ), - auth_needed_to_write: ifDefinedFirstElseSecond( - conv.auth_needed_to_write, - DEFAULTS.auth_needed_to_write - ), + auth_needed_to_vote: false, + auth_needed_to_write: false, auth_opt_allow_3rdparty: auth_opt_allow_3rdparty, auth_opt_fb_computed: auth_opt_fb_computed, auth_opt_tw_computed: auth_opt_tw_computed, @@ -12598,10 +12578,6 @@ Thanks for using Polis! let dwok = req.p.dwok; let o: ConversationType = {}; ifDefinedSet("parent_url", req.p, o); - ifDefinedSet("auth_needed_to_vote", req.p, o); - ifDefinedSet("auth_needed_to_write", req.p, o); - ifDefinedSet("auth_opt_fb", req.p, o); - ifDefinedSet("auth_opt_tw", req.p, o); ifDefinedSet("auth_opt_allow_3rdparty", req.p, o); ifDefinedSet("topic", req.p, o); if (!_.isUndefined(req.p.show_vis)) { diff --git a/server/src/utils/constants.ts b/server/src/utils/constants.ts index f0de720983..7186441962 100644 --- a/server/src/utils/constants.ts +++ b/server/src/utils/constants.ts @@ -1,9 +1,9 @@ const DEFAULTS = { auth_needed_to_vote: false, - auth_needed_to_write: true, + auth_needed_to_write: false, auth_opt_allow_3rdparty: true, - auth_opt_fb: true, - auth_opt_tw: true, + auth_opt_fb: false, + auth_opt_tw: false, }; export { DEFAULTS }; From 18fafae8fa33d214eeb81ff8639c1fd6fd23a129 Mon Sep 17 00:00:00 2001 From: tevko Date: Wed, 20 Nov 2024 14:04:28 -0600 Subject: [PATCH 2/3] adjust tests --- e2e/cypress/e2e/client-admin/conversation.cy.js | 4 ---- e2e/cypress/e2e/client-admin/share.cy.js | 1 - e2e/cypress/e2e/client-participation/social-login.cy.js | 5 +++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/e2e/cypress/e2e/client-admin/conversation.cy.js b/e2e/cypress/e2e/client-admin/conversation.cy.js index f5a8f8230b..cd65025602 100644 --- a/e2e/cypress/e2e/client-admin/conversation.cy.js +++ b/e2e/cypress/e2e/client-admin/conversation.cy.js @@ -23,14 +23,10 @@ describe('Conversation: Configure', function () { cy.get('input[data-test-id="write_type"]').should('be.checked') cy.get('input[data-test-id="help_type"]').should('be.checked') cy.get('input[data-test-id="subscribe_type"]').should('be.checked') - cy.get('input[data-test-id="auth_opt_fb"]').should('be.checked') - cy.get('input[data-test-id="auth_opt_tw"]').should('be.checked') // Schemes section cy.get('input[data-test-id="is_active"]').should('be.checked') cy.get('input[data-test-id="strict_moderation"]').should('not.be.checked') - cy.get('input[data-test-id="auth_needed_to_write"]').should('be.checked') - cy.get('input[data-test-id="auth_needed_to_vote"]').should('not.be.checked') }) it('should create a new conversation with a topic and description', function () { diff --git a/e2e/cypress/e2e/client-admin/share.cy.js b/e2e/cypress/e2e/client-admin/share.cy.js index 122c91f230..b0f5610d92 100644 --- a/e2e/cypress/e2e/client-admin/share.cy.js +++ b/e2e/cypress/e2e/client-admin/share.cy.js @@ -8,7 +8,6 @@ describe('Share page', function () { .then(() => cy.visit(this.adminPath)) cy.get('input[data-test-id="strict_moderation"]').check() - cy.get('input[data-test-id="auth_needed_to_write"]').uncheck() }) beforeEach(function () { diff --git a/e2e/cypress/e2e/client-participation/social-login.cy.js b/e2e/cypress/e2e/client-participation/social-login.cy.js index f614677747..f559bb54b9 100644 --- a/e2e/cypress/e2e/client-participation/social-login.cy.js +++ b/e2e/cypress/e2e/client-participation/social-login.cy.js @@ -6,8 +6,9 @@ const facebookVoteBtn = 'button#facebookButtonVoteView' const twitterAuthOpt = 'input[data-test-id="auth_opt_tw"]' const twitterCommentBtn = 'button#twitterButtonCommentForm' const twitterVoteBtn = 'button#twitterButtonVoteView' - -describe('Social login buttons', function () { +// skip this test for now +// eslint-disable-next-line mocha/no-skipped-tests +describe.skip('Social login buttons', function () { before(function () { cy.createConvo().then(() => { cy.seedComment(this.convoId) From 3a0451ac288293ab209a6a6ecc992d69f2e7d1cc Mon Sep 17 00:00:00 2001 From: tevko Date: Wed, 20 Nov 2024 15:39:43 -0600 Subject: [PATCH 3/3] remove auth from views --- .../conversation-admin/conversation-config.js | 20 ------------------- .../js/templates/vote-view.handlebars | 6 ++++++ client-participation/js/views/comment-form.js | 6 +++--- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/client-admin/src/components/conversation-admin/conversation-config.js b/client-admin/src/components/conversation-admin/conversation-config.js index ae8d18cbd9..86191259a1 100644 --- a/client-admin/src/components/conversation-admin/conversation-config.js +++ b/client-admin/src/components/conversation-admin/conversation-config.js @@ -166,14 +166,6 @@ class ConversationConfig extends React.Component { notifications when there are new comments to vote on. - - Show Facebook login prompt - - - - Show Twitter login prompt - - No comments shown without moderator approval - - - Participants cannot submit comments without first connecting either - Facebook or Twitter - - - - Participants cannot vote without first connecting either Facebook or - Twitter - ) } diff --git a/client-participation/js/templates/vote-view.handlebars b/client-participation/js/templates/vote-view.handlebars index a42efc69e4..e032bd36dd 100644 --- a/client-participation/js/templates/vote-view.handlebars +++ b/client-participation/js/templates/vote-view.handlebars @@ -3,6 +3,12 @@
+{{#if needSocial}} +{{!-- ================ CONNECT FACEBOOK / TWITTER ================ --}} + + +{{else}} {{!-- !needSocial --}} + {{#if empty}}
{{!-- empty scenario div --}} {{#if subscribed}} diff --git a/client-participation/js/views/comment-form.js b/client-participation/js/views/comment-form.js index 4aa052f51d..a1c0dee780 100644 --- a/client-participation/js/views/comment-form.js +++ b/client-participation/js/views/comment-form.js @@ -44,8 +44,8 @@ module.exports = Handlebones.ModelView.extend({ Utils.shouldFocusOnTextareaWhenWritePaneShown(); ctx.hasTwitter = userObject.hasTwitter; ctx.hasFacebook = userObject.hasFacebook && Constants.FB_APP_ID; - ctx.auth_opt_tw = preload.firstConv.auth_opt_tw; - ctx.auth_opt_fb = preload.firstConv.auth_opt_fb; + ctx.auth_opt_tw = false; + ctx.auth_opt_fb = false; ctx.s = Strings; ctx.desktop = !display.xs(); ctx.hideHelp = !Utils.userCanSeeHelp() || preload.firstConv.help_type === 0; @@ -251,7 +251,7 @@ module.exports = Handlebones.ModelView.extend({ window.userObject.hasFacebook || window.userObject.hasTwitter || !_.isUndefined(xid); - var needsSocial = preload.firstConv.auth_needed_to_write; + var needsSocial = false; M.add(M.COMMENT_SUBMIT_CLICK); if (hasSocial || !needsSocial) { M.add(M.COMMENT_SUBMIT_INIT);