1298 Commits

Author SHA1 Message Date
Kanmaniselvan Murugesan
bafc23eae5 Issue 4895: Add after_database_authentication callback after sign_in immediately after password update (#4916) 2018-11-22 19:13:55 -02:00
Leonardo Tegon
aa6cb411bc Add missing specs for #find_or_initialize_with_errors
After merging https://github.com/plataformatec/devise/pull/4797, I
noticed that we had no specs for the scenarios where this method was
adding the errors to the resource. This commit adds tests to cover those
cases.
2018-11-22 18:44:09 -02:00
Ryan Lue
354df3bc65 [bugfix] [refactoring] Sanitize parameters in find_or_initialize_with_errors (#4797)
* Use parameter sanitizer for new records in find_or_initialize_with_errors

* Add test for find_or_initialize_with_errors bugfix
2018-11-22 15:10:50 -02:00
Leonardo Tegon
05bf574799 Add more tests (#4970)
After merging #4261, I realized that we could add a couple more
tests, to ensure the new behavior added to `#valid_password?` - which is
that it should return `false` when the password is either `nil` or blank
('').
I've also removed [this
condition](https://github.com/plataformatec/devise/blob/master/lib/devise/models/database_authenticatable.rb#L68)
because it's already present at `Devise::Encryptor` module in the
`.compare`
[method](https://github.com/plataformatec/devise/blob/master/lib/devise/encryptor.rb#L15).
2018-11-13 15:29:14 -02:00
Colin Ross
40f02ae69b Only flash if the request object that is loaded supports it (#4950) 2018-11-13 15:26:00 -02:00
sivagollapalli
3aedbf0a4d [#4245] Allowing password to nil (#4261)
* [#4245] Allowing password to nil

* Set encrypted password to nil if password is nil

* [#4245] Fixing the build

* Removed unnecessary code
2018-11-13 13:57:23 -02:00
Isaac Orme
25f908ad9c issue 4526 adds skip email and password change notifications methods (#4824) 2018-09-28 18:55:00 -03:00
Josh Pencheon
31aceeb104 Fix bug: ParameterFilter should not add keys (#3431) (#4457)
If called with a hash that has a `default` / `default_proc`
configured, `Devise::ParameterFilter` can add in missing keys
it was due to attempt to sanitise the values for.

This patch prevents this from happening, whilst also clarifying
the filtering intent of `ParamaterFilter`.

(This can also occur if NilClass has been augmented with definitions
for `strip` or `downcase`.)

Fixes #3431.
2018-05-15 10:47:18 -03:00
Gencer W. Genç
6c916488af find auto-generated secret_key_base in development (#4869)
With this fix, we will try latest changes in Rails 5.2 together with standard auto-generated secret_key_base in development as a fallback.

If no specified key found, auto-generated value will be used instead.
2018-05-14 18:09:25 -03:00
Andrey Andreev
8866b8e5eb Fix error when params is not a hash 2018-05-09 14:56:50 -03:00
Tony Correia
1c8e97c75a Issue 4763: Change login errors for when in paranoid mode 2018-05-09 10:49:27 -03:00
Max Kramer
b20de505ab Split IP resolution from update_tracked_fields
This permits users to easily customize where the ip address
should be resolved.  When fronting the application with a webserver or
load balancer, the ip address may be the server and not be the user.

E.g. consider the IP address is passed as the header: "X-Forwarded-For".

```ruby
class User
  devise :trackable

  protected
    def extract_ip_from(request)
      request.headers["X-Forwarded-For"]
    end
end
```
2018-04-03 09:53:28 -03:00
Koichi ITO
dac90eeb80 Use update instead of update_attributes
`update_attributes` and `update_attributes!` will be deprecated in Rails 6.

Refer 5645149d3a
2018-03-29 15:39:24 -03:00
Wolfram Nikolas Müller
f220b992c3 add test for lazy loading hook 2018-03-29 15:32:46 -03:00
Leonardo Tegon
962cea2039 Create Devise::SecretKeyFinder
When supporting Rails 5.2 credentials on
https://github.com/plataformatec/devise/pull/4712, we ended up breaking
apps that were upgraded to Rails 5.2 and weren't using `credentials`
to store their `secret_key_base`. See
https://github.com/plataformatec/devise/issues/4807 for more context.
To fix it, we're now checking whether the key is present before using it.
Since there weren't any automated test for this - the conditionals were
in a Rails engine initializer - I've extracted it to a new class so that
we are able to test it easily.

Fixes #4807
2018-03-17 20:28:38 -03:00
Leonardo Tegon
3722aa6296 Revert "Replace log_process_action to append_info_to_payload" 2018-03-15 09:43:12 -03:00
Leonardo Tegon
5664b19703 Ensure Devise isn't performing model validations 2018-03-14 15:21:07 -03:00
Gordon McNaughton
3e23371b01 Preserve content_type for unauthenticated tests
In Rails 4, for unauthenticated controller tests which trigger the
failure app, ensure that the simulated failure response includes a
content_type (broken in bb44d42).

This works in Rails5, which parses the content-type header on-demand,
but not in Rails4 which requires setting the response's content_type
explicitly.

Fixes #4783.
2018-02-26 12:15:36 -05:00
Justin Coyne
a45bbe1783 Test on Rails 5.2.0.rc1 (#4711) 2018-02-22 10:05:19 -03:00
Leonardo Tegon
d1948b79d3 Fix ActiveRecord check on Confirmable (#4752)
* Fix `ActiveRecord` check on `Confirmable`

As pointed out by @dark-panda in #4302, the condition for an
`ActiveRecord` model is wrong inside the `Confirmable` initialization
block.

https://github.com/plataformatec/devise/pull/4302#issuecomment-355103489

* Add specs
2018-01-16 10:25:20 -02:00
Filip Soszyński
b01ae718b3 Primary key type in migration template (#4426)
* Tests

* Add primary key type to migration template

* Change Rails version-detecting method in test
2017-12-23 17:20:45 -02:00
Rafael França
0720bc72c3 Merge pull request #4731 from alexhifer/master
Added the ability to change the default migrations path
2017-12-21 18:33:07 -05:00
Pat Allan
f39c6fd927 Add the frozen_string_literal pragma comment to all Ruby files. (#4725) 2017-12-21 15:36:29 -02:00
Guilherme Goettems Schneider
8b9fba73fd Allow frozen options in as_json (#4655)
The test uses `as_json` instead of `to_json` because `to_json` does `#dup` on `options` before it reaches `#serializable_hash` and the test would pass without the fix.
2017-12-21 15:23:25 -02:00
Alexey Degtyarev
12298ef968 Added the ability to change the default migrations path (introduced in Rails 5.0.3) 2017-12-21 17:12:19 +02:00
Ashley Foster
31801fc9a0 Fix missing validations on Signup (#4674)
* Fix missing validations on Signup

This commit fixes issue
https://github.com/plataformatec/devise/issues/4673

This removes `validate: false` from saving a record when `Trackable` is
in use.

* Add test case

* Add mongoid model
2017-11-28 12:58:41 -02:00
Rafael França
701d4929d8 Merge pull request #4375 from fbbergamo/change-status-append
Replace log_process_action to append_info_to_payload
2017-11-22 15:53:28 -05:00
Rafael França
840c2e7306 Merge pull request #4686 from kyoshidajp/fix_mongoid_failed_test
Fix mongoid test failed problem
2017-10-31 01:44:48 -04:00
Masato Oba
975bb8490d Fix typo 'an user' to 'a user' 2017-10-29 12:31:06 +00:00
Masato Oba
6ceb649b10 Fix small typo in authenticatable_test.rb 2017-10-29 12:10:39 +00:00
Katsuhiko YOSHIDA
bcb67ecde8 Fix mongoid test failed problem 2017-10-28 15:56:32 +09:00
Pat Allan
4e9860d268 Ensure string literals can be frozen. 2017-06-21 09:22:49 +10:00
Dan Schultzer
be2e17841e Separate Devise test methods from Devise 2017-04-29 10:24:22 -07:00
Rafael Mendonça França
0591d92f53 Move the version check to the lib folder
Closes #4514.
Fixes #4513.
2017-04-29 10:12:51 -07:00
Rafael Mendonça França
94c6d5f5cc Remove deprecation on _changed? methods 2017-04-28 16:05:39 -07:00
Rafael França
4beeca46c4 Merge pull request #4512 from jcoyne/rails-5.1
Rails 5.1
2017-04-28 15:16:35 -07:00
Matthew Rudy Jacobs
7c4e8c8d17 Rails 5.1 requires ActionController::TestRequest to have a controller class
Pass it in as an anonymous class
2017-04-28 10:51:27 -05:00
Felipe Bergamo
6eb412efae Typo test doc 2017-04-24 18:38:49 -03:00
Carlos Antonio da Silva
ce071502ee Display unconfirmed email when using reconfirmable and email changed notification
Otherwise we'd be mistakenly displaying the original email in the
message (which is the same we're sending the message to).

Also tweak the messaging a bit in this case, to show that the email "is
being changed" (the change hasn't taken effect yet).

Related to #4455.
2017-03-15 11:47:47 -03:00
Carlos Antonio da Silva
0c5d78e31c Merge pull request #4456 from victor-am/hotfix_absent_new_password_values
Fix absent password params from Password#update

Closes #4397.
2017-03-13 19:41:46 -03:00
victor-am
60dc4be8c1 Fix absent password params from Password#update
Related to issue #4397

This hotfix adds a string coercion to new_password paramenters when
trying to reset an user's password.

Before that, when a user submitted a password recovery form with the
new_password and new_password_confirmation params as nil, Devise would
sign in the user with a success notice but without actually changing the
password.
2017-03-10 14:29:25 -03:00
Carlos Antonio da Silva
c605758800 Add some basic tests for the email changed notification 2017-03-10 09:10:57 -03:00
Carlos Antonio da Silva
2135ae5e5e Change email_change => email_changed notification
This better indicates what the setting is for, and when it's supposed to
be triggered.

We might eventually deprecate the existing password_change on in favor
of password_changed.
2017-03-10 08:56:34 -03:00
Carlos Antonio da Silva
8387cc9474 When using reconfirmable, notify the original email about the change right away
Do not wait for the email change to be confirmed by the "unconfirmed
email" with reconfirmable: notify the original email right away.
2017-03-06 17:07:55 -03:00
Carlos Antonio da Silva
70eb18d766 Notify original user email when the email changes
This adds a new setting `send_email_change_notification` which will
send an email to the original user email when their email is updated to
a new one.

It doesn't take into account the reconfirmable setting yet, it will be
added next, so that if confirmable is included and reconfirmable is
being used, the email will be triggered when the email change is
requested, not when confirmed (e.g when we store the email in
`unconfirmed_email`, not when it's later copied to `email` when that is
confirmed).
2017-03-06 17:04:26 -03:00
Carlos Antonio da Silva
c76f0e59b7 Use assert_nil to prevent minitest warnings 2017-03-02 08:12:46 -03:00
Matthew Rudy Jacobs
6fc6a28e3b Avoid the assert_equal nil deprecation warning 2017-02-26 22:05:15 +00:00
Matthew Rudy Jacobs
6bc2db4567 Fix Omniauth config tests 2017-02-26 21:52:51 +00:00
Felipe Bergamo
9caae50339 Replace log_process_action to append_info_to_payload 2016-12-10 18:40:57 -02:00
Marc G Gauthier
8ee01fc10b Fix a minor typo in specs
There is nothing much to this one, it's in the test description so it shouldn't impact a thing and will make this line more greppable.
2016-08-11 09:56:45 +02:00