Commit Graph

83 Commits

Author SHA1 Message Date
Iraline
5eb2dc5a9c adding limitation to not save blank email in model 2022-06-07 14:17:37 -03:00
Iraline
0195eac3fa change the code to use what Devise does by default and update the tests 2022-05-09 18:14:12 -03:00
Iraline
4fd6253a00 Permit use confirmation token only when user create a new account or change the email 2022-05-05 16:54:56 -03:00
Iraline
54ec44742b pronto run 2022-05-05 14:52:18 -03:00
iraline
f253518e1a Merge branch 'consul:master' into fix_confirmation_token_2746 2022-04-26 09:50:57 -03:00
Sebastia
7d1c67261c Merge pull request #4228 from consul/already_confirmed_user_emails
Send informative email for already confirmed users
2022-04-20 09:54:37 +02:00
Julian Herrero
ad018c6f39 Send informative email for already confirmed users
Currently the application does not send any email to confirm the
account for already confirmed users. But we show a notice message
that may look like you will recive one:

"If your email address exists in our database, you will receive
 an email with instructions for how to confirm your email address
 in a few minutes."

In this commit we keep the original message, but send an email to
the user informing them that their account is now registered.

This way no one can know if someone else's account is confirmed and
we don't have to worry about GDPR either.

Co-Authored-By: taitus <sebastia.roig@gmail.com>
2022-04-19 17:03:02 +02:00
Iraline
6c03e258fa Added conditional to check if token has already been used 2022-04-18 13:56:18 -03:00
Javi Martín
11832cc07d Make it easier to customize allowed parameters
When customizing CONSUL, one of the most common actions is adding a new
field to a form.

This requires modifying the permitted/allowed parameters. However, in
most cases, the method returning these parameters returned an instance
of `ActionController::Parameters`, so adding more parameters to it
wasn't easy.

So customizing the code required copying the method returning those
parameters and adding the new ones. For example:

```
def something_params
  params.require(:something).permit(
    :one_consul_attribute,
    :another_consul_attribute,
    :my_custom_attribute
  )
end
```

This meant that, if the `something_params` method changed in CONSUL, the
customization of this method had to be updated as well.

So we're extracting the logic returning the parameters to a method which
returns an array. Now this code can be customized without copying the
original method:

```
alias_method :consul_allowed_params, :allowed_params

def allowed_params
  consul_allowed_params + [:my_custom_attribute]
end
```
2022-04-07 19:35:40 +02:00
Javi Martín
57d8a59d10 Add an apply Style/RaiseArgs rubocop rule
We were already applying it most of the time.
2021-08-09 17:32:46 +02:00
Javi Martín
83e4633643 Don't redirect to POST request URLs after sign out
Sometimes we define URLs for POST requests which are not defined for GET
requests, such as "/residence", so redirecting to it after signing out
results in a routing error.

So instead of using the request referer, we're using the stored location
devise uses, and we're not storing locations in POST requests.
2020-08-11 18:19:48 +02:00
Julian Herrero
193e51d42f Enable Wordpress Oauth login and registration 2020-02-07 12:23:41 +07:00
Javi Martín
d0d681a44b Add and apply EmptyLineAfterGuardClause rule
We were inconsistent on this one. I consider it particularly useful when
a method starts with a `return` statement.

In other cases, we probably shouldn't have a guard rule in the middle of
a method in any case, but that's a different refactoring.
2019-10-24 17:56:03 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Javi Martín
7ca55c44e0 Apply Rails/SaveBang rubocop rule
Having exceptions is better than having silent bugs.

There are a few methods I've kept the same way they were.

The `RelatedContentScore#score_with_opposite` method is a bit peculiar:
it creates scores for both itself and the opposite related content,
which means the opposite related content will try to create the same
scores as well.

We've already got a test to check `Budget::Ballot#add_investment` when
creating a line fails ("Edge case voting a non-elegible investment").

Finally, the method `User#send_oauth_confirmation_instructions` doesn't
update the record when the email address isn't already present, leading
to the test "Try to register with the email of an already existing user,
when an unconfirmed email was provided by oauth" fo fail if we raise an
exception for an invalid user. That's because updating a user's email
doesn't update the database automatically, but instead a confirmation
email is sent.

There are also a few false positives for classes which don't have bang
methods (like the GraphQL classes) or destroying attachments.

For these reasons, I'm adding the rule with a "Refactor" severity,
meaning it's a rule we can break if necessary.
2019-10-23 14:39:31 +02:00
Javi Martín
27468b0b7b Use relative URLs where possible
In general, we always use relative URLs (using `_path`), but sometimes
we were accidentally using absolute URLs (using `_url`). It's been
reported i might cause some isuses if accepting both HTTP and HTTPS
connections, although we've never seen the case.

In any case, this change makes the code more consistent and makes the
generated HTML cleaner.
2019-10-20 17:26:14 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
decabeza
4f1e70ea95 Remove redirect to poll officers 2019-05-17 16:30:33 +02:00
Julian Herrero
1a21b779ac Fix deprecation warning calling `env' in controllers 2019-04-17 17:40:55 +02:00
rgarcia
c6ab5dbe1b Remove before_filter deprecation warning
DEPRECATION WARNING: before_filter is deprecated and will be removed in
Rails 5.1. Use before_action instead. (called from
<class:RegistrationsController> at
/home/travis/build/consul/consul/app/controllers/users/registrations_con
troller.rb:3)
2019-04-17 17:40:55 +02:00
rgarcia
4bce38bd64 Fix deprecated devise syntax
https://stackoverflow.com/questions/37341967/rails-5-undefined-method-fo
r-for-devise-on-line-devise-parameter-sanitizer
2019-04-16 17:28:07 +02:00
Javi Martín
78c6395e5f Respond with 404 when confirming an invalid token
We were getting a 500 Internal Server Error because `find_by` returned
`nil`, but the code assumed it returned an object responding to
`encrypted_password`. In this case, maybe some other status code (like
400 or 401) might be more appropriate, but I've kept 404 because it was
easier to implement and I wasn't sure which one was better.

Also note ideally we would test the controller using:

expect(response).to have_http_status(:not_found)

However, we would need to configure the test to show exceptions and not
to consider all requests local. I haven't been able to do so for
controller tests, and doing so for feature/request specs seems to
require changes in the test environment configuration which would affect
other tests.
2019-04-10 12:41:21 +02:00
rgarcia
b4499321d3 stores officer booth on sign in 2019-03-28 15:47:52 +01:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
decabeza
cf7155613e Changes honeypot family name to address on users sign up form 2018-12-21 11:34:12 +01:00
iagirre
6e238ae252 Changed redirection when signing out from management section 2018-07-15 17:35:30 -04:00
rgarcia
5a041e89c4 Fix change email address
Not sure how this error creeped in 😕 probably a new gem version or
other conflicting code

The problem was we were getting an `unpermitted param email` when
updating a user’s email address

This stackoverflow solution seems to work nicely 😌
https://stackoverflow.com/questions/17384289/unpermitted-parameters-addi
ng-new-fields-to-devise-in-rails-4-0#answer-19036427
2018-04-04 14:01:51 +02:00
Bertocq
3a54713ed0 Fix all Rails/DynamicFindBy rubocop issues 2017-07-10 23:04:27 +02:00
Bertocq
28970c6701 Fix all Style/UnneededInterpolation rubocop issues and remove from rubocop_tod 2017-07-04 22:44:08 +02:00
Bertocq
d2e08d1a0c Remove unused param on both method and call, using class variable instead 2017-06-25 15:46:46 +02:00
Bertocq
256eb682d0 Fix Rails/RequestReferer rubocop issue and remove from rubocop_todo list 2017-06-19 10:45:18 +02:00
Bertocq
02524b164a Rubocop autocorrections (indentations, revers unless to if, extra spaces) 2017-06-08 12:14:35 +02:00
rgarcia
bb3c4c6399 adds consistency to ruby code style
Keep a blank line before and after private
Keep a blank line before and after protected
Remove extra empty line at class body end
Remove extra blank line
Add final newline
Use 2 (not 3) spaces for indentation
Use 2 (not 4) spaces for indentation
Remove space before comma
Add space after comma
Remove trailing whitespaces
Remove unnecessary spacing
Use snake_case for variable names
Do not use then for multi-line if
Remove unused block argument - i
Use the new Ruby 1.9 hash syntax
Remove unused assignment to variable
Indent when as deep as case
Align attributes
Align end with def
2016-11-15 11:18:43 +01:00
kikito
9ac6e2d60b Uses invisible_captcha's default "foo fast" action 2016-04-28 12:47:04 +02:00
kikito
303b17c238 Adds invisible_captcha to user & organization registrations 2016-04-27 16:13:50 +02:00
kikito
dea1a28a69 purges simple_captcha 2016-04-27 16:07:47 +02:00
kikito
f86912c77c Adapts to new User api 2016-04-19 13:33:16 +02:00
Juanjo Bazán
87662b3873 makes sure no blank redeemable codes are db stored 2016-02-26 17:55:34 +01:00
kikito
49dec60615 adds a redeemable code to users. It can be filled up when signing up from /cuentasegura 2016-02-22 17:41:08 +01:00
kikito
957e07489a remove unuseful comment 2016-01-26 19:59:20 +01:00
kikito
a796dade7a extracts methods into user.rb 2016-01-26 19:48:01 +01:00
kikito
646ca8a686 Splits omniauth_callbacks_controller#login_with method in two smaller ones
Uses new hash syntax in specs
2016-01-26 18:15:45 +01:00
kikito
1e8d46d83a fixes failing email specs
Conflicts:
	app/models/user.rb

fixes missing i18n entry

fixes badly done merge

fixes i18n issues

force build to start
2016-01-26 18:15:43 +01:00
kikito
a606c7aa8d Renames confirmed_oauth_email to oauth_email
Refactors the way oauth_email is used to cover more cases (fixes pending specs)
2016-01-26 18:15:40 +01:00
kikito
d5eab64568 adds feature flags for omniauth login buttons/controls
Conflicts:
	app/controllers/users/omniauth_callbacks_controller.rb
	app/views/devise/_omniauth_form.html.erb
2016-01-26 18:15:39 +01:00
kikito
98f99954e7 Corrects the logic dealing with confirmations of users via oauth 2016-01-26 18:15:39 +01:00
kikito
7615dc066b Uses registering_with_oauth persistent attribute to deactivate checks in certain occasions 2016-01-26 18:11:11 +01:00
kikito
f74028e3b5 Replaces the OMNIAUTH_REGEX logic with a boolean 2016-01-26 18:11:04 +01:00
kikito
d1741a2b28 Refactor first_or_create_for_auth & its usage
Conflicts:
	app/controllers/users/omniauth_callbacks_controller.rb

Refactors first_or_initialize_for_oauth
2016-01-26 18:10:57 +01:00
Josep Jaume Rey Peroy
cf00f12ec7 Store locale in a user's field and switch locale on mailers 2016-01-22 18:10:28 +01:00