Skip to content

Commit

Permalink
Merge pull request #1840 from compdemocracy/te-remove-twitter-faceboo…
Browse files Browse the repository at this point in the history
…k-auth

disable non functional social auth
  • Loading branch information
tevko authored Nov 21, 2024
2 parents 8704852 + 3a0451a commit 395df42
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,6 @@ class ConversationConfig extends React.Component {
notifications when there are new comments to vote on.
</CheckboxField>

<CheckboxField field="auth_opt_fb" label="Facebook login prompt">
Show Facebook login prompt
</CheckboxField>

<CheckboxField field="auth_opt_tw" label="Twitter login prompt">
Show Twitter login prompt
</CheckboxField>

<Heading
as="h6"
sx={{
Expand All @@ -187,18 +179,6 @@ class ConversationConfig extends React.Component {
<CheckboxField field="strict_moderation">
No comments shown without moderator approval
</CheckboxField>

<CheckboxField
field="auth_needed_to_write"
label="Require Auth to Comment">
Participants cannot submit comments without first connecting either
Facebook or Twitter
</CheckboxField>

<CheckboxField field="auth_needed_to_vote" label="Require Auth to Vote">
Participants cannot vote without first connecting either Facebook or
Twitter
</CheckboxField>
</Box>
)
}
Expand Down
38 changes: 0 additions & 38 deletions client-participation/js/templates/comment-form.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -152,44 +152,6 @@
</span>
</div>

{{!-- ================ CONNECT FACEBOOK / TWITTER ================ --}}
<div
id="socialButtonsCommentForm"
style="
display: none;
margin-top: 10px;
">
<div class="protip"><p><i class="fa fa-microphone"></i>&nbsp; {{s.connectToPostPrompt}}</p></div>
{{#if auth_opt_fb}}
{{#unless hasFacebook}}
<button id="facebookButtonCommentForm" class="facebookButton" style="padding-top: 0px;">
<i class="svgIcon" style="
display: inline-block;
position: relative;
margin-inline-end: 2px;
top: 6px;
width: 25px;
fill: white;
">{{> iconFaFacebookSquare25}}</i>
{{s.connectFacebook}}</button>
{{/unless}}
{{/if}}
{{#if auth_opt_tw}}
{{#unless hasTwitter}}
<button id="twitterButtonCommentForm" class="twitterButton" style="padding-top: 0px;">
<i class="svgIcon" style="
display: inline-block;
position: relative;
margin-inline-end: 2px;
top: 8px;
width: 25px;
fill: white;
">{{> iconFaTwitter25}}</i>
{{s.connectTwitter}}</button>
{{/unless}}
{{/if}}
</div>

{{!-- ================ LOWER CONTAINER ================ --}}
<div
id="comment_form_controls"
Expand Down
37 changes: 1 addition & 36 deletions client-participation/js/templates/vote-view.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,7 @@

{{#if needSocial}}
{{!-- ================ CONNECT FACEBOOK / TWITTER ================ --}}
<div
id="socialButtonsVoteView"
style="
{{!-- display: none; --}}
margin: 10px;
">
<div class="protip"><p><i class="fa fa-microphone"></i>&nbsp; {{s.connectToVotePrompt}}</p></div>
{{#if auth_opt_fb}}
{{#unless hasFacebook}}
<button id="facebookButtonVoteView" class="facebookButton" style="padding-top: 0px; margin-bottom: 4px;">
<i class="svgIcon" style="
display: inline-block;
position: relative;
margin-inline-end: 2px;
top: 6px;
width: 25px;
fill: white;
">{{> iconFaFacebookSquare25}}</i>
{{s.connectFacebook}}</button>
{{/unless}}
{{/if}}
{{#if auth_opt_tw}}
{{#unless hasTwitter}}
<button id="twitterButtonVoteView" class="twitterButton" style="padding-top: 0px; margin-bottom: 4px;">
<i class="svgIcon" style="
display: inline-block;
position: relative;
margin-inline-end: 2px;
top: 8px;
width: 25px;
fill: white;
">{{> iconFaTwitter25}}</i>
{{s.connectTwitter}}</button>
{{/unless}}
{{/if}}
</div>


{{else}} {{!-- !needSocial --}}

Expand Down
6 changes: 3 additions & 3 deletions client-participation/js/views/comment-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions e2e/cypress/e2e/client-admin/conversation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
1 change: 0 additions & 1 deletion e2e/cypress/e2e/client-admin/share.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
5 changes: 3 additions & 2 deletions e2e/cypress/e2e/client-participation/social-login.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
96 changes: 36 additions & 60 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions server/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -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 };
Expand Down

0 comments on commit 395df42

Please sign in to comment.