Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make the invite request field mandatory #15273

Closed
c-chell opened this issue Dec 5, 2020 · 10 comments · Fixed by #15326
Closed

How to make the invite request field mandatory #15273

c-chell opened this issue Dec 5, 2020 · 10 comments · Fixed by #15326
Assignees

Comments

@c-chell
Copy link

c-chell commented Dec 5, 2020

Hello,

On my instance, I activate the manual approval mode for accounts.
Now I'm dealing with high amount of accounts created without the invite field (Why do you want to join?) completed.
I want to make this field mandatory/required.

(after more than hour of search)
I try to edit the file /app/views/auth/registrations/new.html.haml to change to
= invite_request_fields.input :text, as: :text, wrapper: :with_block_label, required: true
(I also run the commands RAILS_ENV=production bundle exec rails assets:precompile and restart mastodon processes after that)

But the field is not required and I can create a test account without this field.

How to make this field mandatory ?
(version 3.2.1)

Thank you.

@mashirozx
Copy link
Contributor

look here
mashirozx@b1e4c5e

@c-chell
Copy link
Author

c-chell commented Dec 5, 2020

Thank you for the link but it's not work.

With this diff :

diff --git a/app/views/about/_registration.html.haml b/app/views/about/_registration.html.haml
index af28e2174..8f313e143 100644
--- a/app/views/about/_registration.html.haml
+++ b/app/views/about/_registration.html.haml
@@ -13,7 +13,7 @@
     - if approved_registrations?
       .fields-group
         = f.simple_fields_for :invite_request do |invite_request_fields|
-          = invite_request_fields.input :text, as: :text, wrapper: :with_block_label, required: false
+          = invite_request_fields.input :text, as: :text, wrapper: :with_block_label, required: true
 
     .fields-group
       = f.input :agreement, as: :boolean, wrapper: :with_label, label: t('auth.checkbox_agreement_html', rules_path: about_more_path, terms_path: terms_path), disabled: closed_registrations?
diff --git a/app/views/auth/registrations/new.html.haml b/app/views/auth/registrations/new.html.haml
index 457bc1d23..4ff972096 100644
--- a/app/views/auth/registrations/new.html.haml
+++ b/app/views/auth/registrations/new.html.haml
@@ -28,7 +28,7 @@
   - if approved_registrations? && !@invite.present?
     .fields-group
       = f.simple_fields_for :invite_request, resource.invite_request || resource.build_invite_request do |invite_request_fields|
-        = invite_request_fields.input :text, as: :text, wrapper: :with_block_label, required: false
+        = invite_request_fields.input :text, as: :text, wrapper: :with_block_label, required: true
 
   = f.input :invite_code, as: :hidden

The field is still not required to validate the registration.

In the HTML the field is marked as required but not block if empty

@ClearlyClaire ClearlyClaire self-assigned this Dec 5, 2020
@ClearlyClaire
Copy link
Contributor

This is something I had planned on working on today, I will do so.

@mashirozx's suggestion seems mostly correct to me, except it won't enforce the verification on the backend. Did you restart mastodon-web?

@c-chell
Copy link
Author

c-chell commented Dec 5, 2020

I recompute the assets (the * for required field is good), and I restart these services :
service mastodon-streaming restart
service mastodon-web restart
service mastodon-sidekiq restart

I don't know what is missing.
(Also even if I'm a developer, I'm mostly on C# and PHP and totally out of Ruby)

@mashirozx
Copy link
Contributor

Seems there is no request field here:
app/views/invites/_form.html.haml

Shall we add logic of pending account with a invite link? (I think this is a bit unreasonal)

@ClearlyClaire
Copy link
Contributor

@c-chell oh, if you're applying this change on top of v3.2.1, you also need to add html: { novalidate: false } to the = simple_form_for( lines in the files you edited

@mashirozx
Copy link
Contributor

uhhh, I'm misunderstanding (・・;)

@c-chell
Copy link
Author

c-chell commented Dec 5, 2020

@c-chell oh, if you're applying this change on top of v3.2.1, you also need to add html: { novalidate: false } to the = simple_form_for( lines in the files you edited

Thank you, now the field is required in the browser; but not on the server, I test it with using the inspector of the browser and if I remove manually the require attribute of the field the account is created.
This is the first step to block spam account creation, thank you for the information.

@c-chell
Copy link
Author

c-chell commented Dec 12, 2020

Thank you @ThibG for your code, I copy it on my custom branch and it's seems to work great.
(Just for my knowledge, do I need to "close" the discussion or do I need to wait the PR validated ? )

@ClearlyClaire
Copy link
Contributor

The issue will automatically be closed when (if) the PR gets merged

ClearlyClaire added a commit to ClearlyClaire/mastodon that referenced this issue Dec 13, 2020
Gargron pushed a commit that referenced this issue Dec 14, 2020
Fixes #15273

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants