Commit Graph

18703 Commits

Author SHA1 Message Date
Javi Martín
0aee568977 Add and apply Rails/RedundantActiveRecordAllMethod
This rule was introduced in rubocop-rails 2.21.0.
2023-11-20 14:22:12 +01:00
Javi Martín
522eb6cfa3 Add and apply Rails/SelectMap rule
This rule was introduced in rubocop-rails 2.21.0. Using `pluck` is
easier to read.
2023-11-20 14:22:12 +01:00
dependabot[bot]
21d39bac62 Bump rubocop-rails from 2.20.2 to 2.21.2
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.20.2 to 2.21.2.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.20.2...v2.21.2)

---
updated-dependencies:
- dependency-name: rubocop-rails
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Note version 2.21.0 relaxes the default `Include` path for
`Rails/FindEach`, and so this version can find and correct offenses
outside the `app/models/` folder [1].

Also note this version replaces `unless something.include?` with `if
something.exclude?`; since we don't use the `exclude?` method anywhere,
we're removing the `include?` method from the list of methods checked by
this cop.

Finally, the Rails/HttpStatus method now returns a false positive when
rendering a dashboard partial and passing the `status` variable. In
order to avoid this issue, we could change the name of the local
variable or move the partial to a component, but for now we're simply
excluding these files for this cop.

[1] https://github.com/rubocop/rubocop-rails/pull/1059/commits/0066b3505

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 14:22:09 +01:00
Javi Martín
96580afe16 Merge pull request #5178 from consuldemocracy/dependabot/bundler/puma-5.6.7
Bump puma from 4.3.12 to 5.6.7
2023-11-20 13:20:56 +01:00
taitus
a93d9789bb Bump rails from 6.1.7.4 to 6.1.7.6 2023-11-17 15:22:28 +01:00
Senén Rodero Rodríguez
2856a0f396 Use the absolute path to fnm binary
Otherwise the Capistrano task `puma:systemd:config` generates a
wrong ExecStart command for puma service that fails on launching.
2023-11-16 17:08:28 +01:00
Javi Martín
e0aee199e4 Merge pull request #5259 from consuldemocracy/dependabot/bundler/rubocop-capybara-2.19.0
Bump rubocop-capybara from 2.18.0 to 2.19.0
2023-11-14 14:31:00 +01:00
Sebastia
c816c51787 Merge pull request #5173 from consuldemocracy/budget_results
Replace back link on budget results
2023-11-14 10:08:31 +01:00
Javi Martín
5e7b5ccfd3 Add and apply Capybara/ClickLinkOrButtonStyle rule
This rule was added in rubocop-capybara 2.19.0. We were following it
most of the time.
2023-11-08 14:18:16 +01:00
Javi Martín
0cec581ec0 Add and apply Capybara/RSpec/HaveSelector rule
This rule was added in rubocop-capybara 2.19.0. We were following it
about 85% of the time.

Now we won't have to check both have_css and have_selector when
searching the code.
2023-11-08 14:18:16 +01:00
dependabot[bot]
83f3cbc143 Bump rubocop-capybara from 2.18.0 to 2.19.0
Bumps [rubocop-capybara](https://github.com/rubocop/rubocop-capybara) from 2.18.0 to 2.19.0.
- [Release notes](https://github.com/rubocop/rubocop-capybara/releases)
- [Changelog](https://github.com/rubocop/rubocop-capybara/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-capybara/compare/v2.18.0...v2.19.0)

---
updated-dependencies:
- dependency-name: rubocop-capybara
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-08 14:18:16 +01:00
Javi Martín
2d30f5180b Merge pull request #5268 from consuldemocracy/dependabot/bundler/rubocop-rspec-2.24.1
Bump rubocop-rspec from 2.23.2 to 2.24.1
2023-11-08 14:17:10 +01:00
Alberto
f563fc0b24 Replace back link on budget executions 2023-11-03 10:57:24 +01:00
Alberto
ea38b6d6c5 Replace back link on budget stats 2023-11-03 10:57:07 +01:00
Senén Rodero
09ca9720f5 Merge pull request #5302 from consuldemocracy/cabildo_tenerife_authetication_logs
ENS: Log successful and failed sign in attempts
2023-10-25 13:14:01 +02:00
Senén Rodero Rodríguez
9112d2d73b Include a timestamp in every authentication logger message 2023-10-25 10:13:04 +02:00
Senén Rodero Rodríguez
b7073691f1 Log successful and failed login attempts in a separate log file
We log the login parameter and the request IP address.

Quoting the ENS:

> [op.acc.5.r5.1] Se registrarán los accesos con éxito y los fallidos.
2023-10-25 10:13:03 +02:00
dependabot[bot]
f7164d3401 Bump puma from 4.3.12 to 5.6.7
Bumps [puma](https://github.com/puma/puma) from 4.3.12 to 5.6.7.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v4.3.12...v5.6.7)

---
updated-dependencies:
- dependency-name: puma
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-24 23:00:12 +02:00
Javi Martín
d8d4c1e9a4 Use systemd to start and monitor puma
Puma 4 is no longer maintained, and Puma 5 removed the option to run
Puma as as daemon. That means that, in order to upgrade, we need to rely
in a process monitoring tool. We're using systemd because it's installed
by default in most (all?) operating systems running Consul Democracy on
production and it's supported by both Puma and the capistrano3-puma gem.

Using systemd means Puma will be automatically started whenever it
crashes, so we no longer need the changes done in commit 40b3c9f2c and
we can now use the default tasks configuration in capistrano3-puma and
capistrano3-delayed-job.

Since Puma is also started automatically when booting the system, we
don't need a cron job to do so anymore and can remove it from the
`schedule.rb` file.
2023-10-24 23:00:12 +02:00
Javi Martín
b59899e9f7 Add and apply RSpec/MetadataStyle rubocop rule
This rule was introduced in rubocop-rspec 2.24.0. We were applying it
most of the time.
2023-10-24 22:59:05 +02:00
Javi Martín
013f3282e4 Use the RSpec/FilePath rule replacements
RSpec/FilePath is deprecated since rubocop-rspec 2.24.0 and will be
removed in rubocop-rspec 3.0 in favor of RSpec/SpecFilePathFormat and
RSpec/SpecFilePathSuffix.
2023-10-24 22:59:05 +02:00
dependabot[bot]
b44247b4e5 Bump rubocop-rspec from 2.23.2 to 2.24.1
Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 2.23.2 to 2.24.1.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.23.2...v2.24.1)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-24 22:59:05 +02:00
Javi Martín
2aff3b73f9 Merge pull request #5273 from consuldemocracy/lockable
ENS: Enable lockable devise module
2023-10-24 22:49:39 +02:00
taitus
d54a5c2ae0 Allow define maximum_attemps and unlock_in 2023-10-24 20:21:03 +02:00
taitus
873ec84b52 Allow disable devise lockable through secrets 2023-10-24 20:20:29 +02:00
taitus
a1955531e1 Enable devise lockable module with default values
In order to the display a warn text on the last attempt
before the account is locked, we need update
config.paranoid to false as the devise documentation
explains.

Adding "config.paranoid: false" implies further changes
to the code, so for now we unncomment the default value
"config.last_attempt_warning = true" and update it to false.
2023-10-24 20:20:27 +02:00
Sebastia
1d5312d2c8 Merge pull request #5163 from consuldemocracy/enable_password_complexity
ENS: Enable password complexity
2023-10-24 19:46:24 +02:00
taitus
7c771b28b5 Add password complexity 2023-10-24 19:00:43 +02:00
taitus
fe9da7988f Enable password_complexity
As it seems that adding complexity to the password is something that
might be wanted from the Consul applications, we added the necessary
changes to allow it.

In this version we simply:
- Uncomment the configuration variable "password_complexity"
- Set this variable without any restrictions
- Adapt the application so that everything still works normally.

One of the things that had to be done to adapt the application
was to remove the overwriting of the "self.included" method.

The original idea of overwriting the "self.included" method seems
to be the possibility of being able to overwrite the
:current_equal_password_validation validation.
The problem comes from the fact that by only calling that validation,
the rest of the validations that are defined (in this case
"password_complexity") are no longer applied.

It seems like a good idea to remove the overwrite of the "self.included"
method to allow all the defined validations to be applied and simply
overwrite the :current_equal_password_validation method so that
everything behaves the same.

:allow_passwords_equal_to_email configuration has been enabled too,
in order to allow existing records with this configuration.

Another change made was to uncomment the line:
and to keep everything working the same set the value to false:
config.email_validation = false.

This change has had to be made because in the documentation of
devise-security it says the following:
In other words, if we want to use the :secure_validatable module
we have to enable this configuration even if its value is "false".

If we kept the configuration variable commented out:
The following error appears:
"uninitialized constant Devise::Models::SecureValidatable::EmailValidator".

So it has been verified that if before making any change we
decommented the line and added the value of "false", the application
worked as normal.
2023-10-24 18:59:03 +02:00
taitus
56aadedc8c Update devise-security.rb
In these commits ffe9ac7 0d8def3 we updated the devise-security version.
In these versions the 'password_regex'  configuration key and some comments
were changed.

We update this file in order to use the new configuration key 'password_complexity' and keep comments updated.
2023-10-24 18:59:03 +02:00
Sebastia
c1e0d58291 Merge pull request #5274 from consuldemocracy/last-sign-in
ENS: Add security secret "last_sign_in"
2023-10-24 18:57:18 +02:00
Javi Martín
ce4939703e Merge pull request #5278 from consuldemocracy/vote_contrast
Make like/unlike buttons more accessible
2023-10-24 17:24:22 +02:00
Javi Martín
77802b90b2 Merge pull request #5282 from consuldemocracy/external_links
Open links in the same tab unless necessary
2023-10-24 17:21:08 +02:00
Javi Martín
827bb125b2 Explicitly open markdown links in the same window
We were already opening them in the same window because we were
accidentall sanitizing the `target` attribute, but now we're making the
point more explicit.
2023-10-24 16:41:03 +02:00
Javi Martín
aeff8a0f31 Don't open auto links in a new tab
Just like we aren't opening any external links in a new tab, only, in
this case, we don't even know whether these links are internal or
external.
2023-10-24 16:41:03 +02:00
Javi Martín
5aa56c054f Mark external links using the "rel" attribute
This will help search engines know these links point to external sites
and it'll make it possible to style these links using the
`[rel~=external]` selector. AFAIK, assistive techonologies don't use
this attribute to notify people about external links, though.
2023-10-24 16:41:03 +02:00
Javi Martín
79c1aa0755 Fix "rel" attribute in footer description links
We were accidentally filtering this attribute when sanitizing the text
since commit 928312e21.
2023-10-24 16:41:03 +02:00
Javi Martín
8053cc5e1c Open footer description links in the same window
This is a funny one, because we were accidentally opening them in the
same window without intending to do so since commit 928312e21, since the
`sanitize` method removes the `target` attribute. So the test we're
adding already passed without these changes.
2023-10-24 16:41:03 +02:00
Javi Martín
05345fb43c Extract methods in footer component
This way it'll be easier to change and refactor this code.
2023-10-24 16:41:03 +02:00
Javi Martín
219d71baaf Open links to external videos in the same window
Just like we're doing with other external links.

We already mention that it's an external video, so there's no need to
explicitly indicate it in the link.
2023-10-24 16:41:03 +02:00
Javi Martín
56d834783c Open links to social networks in the same window
As mentioned in earlier commits, opening external links in a new
tab/window results in usability and accessibility issues.

Since these links are usually at the top or bottom of the page and
contain icons of well-known sites, IMHO there's no need to even notify
people that these are external links.

Since we're no longer using the `shared.target_blank` translation inside
a sentence, we can remove the space and parenthesis in the translations.
2023-10-24 16:41:03 +02:00
Javi Martín
44f4bdf772 Open links to download files in the same tab
Just like we did for documents in commit cdc5e05d4.
2023-10-24 16:40:52 +02:00
Javi Martín
d5c6d1ffab Open links to images in the same tab
Just like we did for documents in commit cdc5e05d4.
2023-10-24 16:34:29 +02:00
Javi Martín
0edfd0cab5 Open management links in the same window
We were doing it this way because managers usually have the management
section open at all times. However, this might not always be the case,
and by opening links in a new tab, we're taking control away from them.

If managers would like to keep the management section open, they can
open the link in a new tab, and if they open it in the same tab, they
can go back to the management section by either clicking the browser's
back button or clicking on the navigation link to the management
section.
2023-10-24 16:31:39 +02:00
Javi Martín
87d7923f0d Open mailer links in the same window
We do it most of the time, so I'm not sure why we weren't doing it in
these cases.
2023-10-24 16:31:39 +02:00
Javi Martín
3753c42ab2 Open moderation links in the same window
Note that, unlike what we did in the admin section we're opening links
to budget investments on the same tab. There are two reasons for it; the
first one is that, in this case, there are no filters in the moderation
section that are lost after editing an investment, and the second one is
that, in this context, administrators usually don't go to the investment
in order to edit it, so they can just check something and use the
browser's back button to go back.
2023-10-24 16:31:39 +02:00
Javi Martín
5c7d87f763 Open admin links in the same window
In the admin section, when clicking on a link that leads to a page in
the public area, sometimes the page was opened in the same window and
sometimes it would open in a new window, with no clear criteria
regarding when either scenario would take place.

This was really confusing, so now we're more consistent and open
(almost) every link in the same window. The main reason behind it is
simple: if we add `target: _blank`, people who want to open those links
in the same window can no longer do so, so we're taking control away
from them. However, if we don't add this attribute, people can choose
whether to open the link on the same tab or to open it on a new one,
since all browsers implement a method to do so.

More reasons behind this decision can be found in "Opening Links in New
Browser Windows and Tabs" [1].

We're keeping some exceptions, though:

* Opening the link to edit an investment on the same tab would result in
  losing all the investment filters already applied when searching for
  investments, so until we implement a way to keep these filters, we're
  also opening the link to edit an investment in a new tab
* For now, we're also opening links to download files in a new window;
  we'll deal with this case in the future

[1] https://www.nngroup.com/articles/new-browser-windows-and-tabs/
2023-10-24 16:31:39 +02:00
Javi Martín
f21eca4ccc Open custom dashboard links in the same window
We were opening these links in a new tab/window because we assume they
were external links.

But, on the one hand, we don't even know whether these links are
external, since they could also point to URLs from our site. And, on the
other hand, opening external links in new windows results in usability
issues as well [1, 2].

On top of that, old browsers have security issues when opening links in
new tabs unless we add `rel="noopener"` [3], and we aren't doing so.

[1] https://www.nngroup.com/articles/new-browser-windows-and-tabs
[2] https://css-tricks.com/use-target_blank
[3] https://mathiasbynens.github.io/rel-noopener/
2023-10-24 16:31:39 +02:00
Javi Martín
0c14feee19 Open proposals dashboard links in the same window
Out of the usability issues I've experienced when using Consul
Democracy, the biggest one has arguably been the fact that the link to
edit a proposal opens in a new tab. I guess the reasoning behind it is
that the page to edit a proposal is not part of the proposals dashboard,
but what the hell! Imagine if every link to edit something opened in a
new tab...

So we're reducing the impact of this nonsense by opening most dashboard
links in the same window; for now, we're still opening in a new window
links to download files and links that might point to external websites.
We'll address those ones in the future.
2023-10-24 16:31:39 +02:00
Javi Martín
ef7486ddc6 Remove empty link in mailer layout
This link was opening the current page in a new window, which is pretty
useless IMHO.
2023-10-24 16:31:39 +02:00