Compare commits

...

55 Commits

Author SHA1 Message Date
Leonardo Tegon
3080e9e018 Don't run ruby 2.5.0 with rails 4.1
https://github.com/rails/rails/issues/25125
2017-12-29 16:42:58 -02:00
Leonardo Tegon
caf633854d Run gem update --system before install on CI
There's an issue with the combination of Bundler `1.16.1` and rubygems `2.7.3`.
This command will install rubygems `2.7.4` in order to fix it.

https://github.com/travis-ci/travis-ci/issues/8978
2017-12-29 16:11:04 -02:00
Leonardo Tegon
f016e823cd Use rdoc 5.1 for ruby 2.1 on CI
`rdoc 6.0` requires ruby version >= `2.2.2`
2017-12-29 16:09:51 -02:00
Leonardo Tegon
9843cb27dc Run tests on ruby 2.5.0 2017-12-29 15:08:49 -02:00
Leonardo Tegon
50bbb56576 Prepare for 4.4.0 release 2017-12-29 14:34:02 -02:00
Leonardo Tegon
135d898e0e Update CHANGELOG.md 2017-12-26 07:59:48 -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
fjg
8c9cc8d355 Change the way to detect ActiveRecord vs Mongoid (#4302)
* Change the way to detect ActiveRecord vs Mongoid

Cause of **mongoid-paperclip** declaring *after_commit* callback while **mongoid** (and MongoDB) does not support it.

* Update test for ActiveRecord presence to handle Mongoid/ActiveRecord project
2017-12-23 16:39:39 -02:00
Anton Davydov
95689757c0 Delete unnecessary condition for helper method (#4359) 2017-12-22 15:38: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
Leonardo Tegon
5f1c210511 Update CHANGELOG.md [ci skip] 2017-12-21 17:15:01 -02:00
Mike Rogers
16b3d6d67c Adding autocomplete="email" to email fields (#4643)
As discussed in https://github.com/plataformatec/devise/issues/4635
2017-12-21 17:13:50 -02:00
Lutz Lengemann
7b3081760f Move failed_attempts increment into its a function (#4351)
With this change one can overwrite when the incrementation is handled without duplicating the other `valid_for_authentication` logic.
2017-12-21 16:49:09 -02:00
Olivier Lacan
5a3b7a1771 Clarify how store_location_for modifies URIs (#4391)
This fairly straightforward refactor extracts the most obtuse
portions of store_location_for into the following discrete
private methods:
- extract_path_from_location
- remove_domain_from_uri
- add_fragment_back_to_path

This may seem like indirection but it was very unclear what
operation was being performed on the location sent to
store_location_for prior to this change.

I considered documenting the behavior but the code seemed
like a prime candidate for method extraction.
2017-12-21 16:15:53 -02:00
Sai Chander
db011c0192 set_flash_method! instead of set_flash_method in omniauth callbacks controller (#4680) 2017-12-21 15:53:14 -02: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
Paulo Henrique Castro
1b02534bef change validatable docs to match generator (#4727)
lib/generators/templates/devise.rb#L160
2017-12-19 08:34:45 -02:00
Shiva Bhusal
42b68d53a7 Adds Table of content to Readme.md (#4621)
* Adds Table of content to Readme.md

* adds 's' to content
2017-12-17 14:00:32 -02:00
Mark Donald Amobi
4f2e915833 minor grammar fix in rememberable documentation (#4550) 2017-12-07 23:16:27 -02:00
Ahmad hamza
f8c1ee0f90 Added nested attributes example for README (#4434) 2017-12-07 23:13:30 -02:00
Calvin Claus
2458334de6 added note about stopping spring (#4506)
For me it was necessary to stop spring for the route helpers to be defined.
2017-12-07 22:29:41 -02:00
Leonardo Tegon
451ba5362b Update changelog [ci skip] 2017-11-28 13:03:53 -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
Felipe Renan
ce0414271a Merge pull request #4704 from plataformatec/plataformatec/issue-template
Add issue template
2017-11-22 20:07:44 -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
Felipe Renan
e61f4bae40 Add issue template
The issue template is a guide to help the contributors report issues.
2017-11-22 18:39:01 -02:00
Rafael França
88e9a85d6a Merge pull request #4694 from rpbaptist/devise_scope-doc
Provide additional info on devise_scope usage
2017-11-06 11:37:55 -05:00
Richard Baptist
d6ffa8ef22 Provide additional info on devise_scope usage 2017-11-06 17:25:29 +01:00
Rafael França
448106f458 Merge pull request #4692 from masatooba/fix-rake-to-rails
Change `rake secret` to `rails secret` in comments
2017-11-02 22:58:56 -04:00
Masato Oba
a88f88eb4b Change rake secret to rails secret in comments 2017-11-02 15:38:32 +00:00
Rafael França
2b10d517f6 Merge pull request #4683 from masatooba/remove-unnecessary-method
Remove unnecessary hide! method definition
2017-10-31 01:51:16 -04:00
Rafael França
4db1d819b0 Merge pull request #4682 from haneru/edit-gemfile
Removed gem minitest
2017-10-31 01:50:37 -04: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
Rafael França
657507b705 Merge pull request #4687 from masatooba/fix-spec-typo
Fix small typo in test
2017-10-30 15:33:35 -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
haneru
4184e23d71 bundle installed 2017-10-28 01:46:55 +09:00
masatooba
a24f98f315 Delete unnecessary hide! method
This method has already been added to Rails.
2017-10-28 01:26:26 +09:00
haneru
c74e2693a3 Removed gem minitest 2017-10-28 01:09:43 +09:00
Rafael França
7a7a099573 Merge pull request #4677 from bananaappletw/master
Remove TODO when Rails 5.0.3 is released
2017-10-23 15:07:09 -04:00
Rafael França
215d034b86 Merge pull request #4645 from swamp09/ci_against
CI against Ruby 2.2.8, 2.3.5, and 2.4.2
2017-10-20 13:34:04 -04:00
Vasiliy Ermolovich
3323197d68 Merge pull request #4668 from pat/mri2.5.0-fix
Fix syntax for MRI 2.5.0-preview1.
2017-10-14 16:25:23 +03:00
Pat Allan
1009096172 Fix syntax for MRI 2.5.0-preview1. 2017-10-13 10:38:43 +11:00
bananaappletw
197ac56520 Remove TODO when Rails 5.0.3 is released 2017-10-07 02:40:32 -07:00
swamp09
92b94bc84d CI against Ruby 2.2.8, 2.3.5, and 2.4.2 2017-09-16 23:40:57 +09:00
Rafael França
71fc5b351a Merge pull request #4565 from pat/frozen-string-literals
Ensure string literals can be frozen.
2017-06-21 14:16:43 -04:00
Pat Allan
4e9860d268 Ensure string literals can be frozen. 2017-06-21 09:22:49 +10:00
Rafael França
ad8547dede Merge pull request #4381 from slbug/master
remove warnings about default value with new thor
2017-06-13 15:51:20 -04:00
Lucas Mazza
079ed3b6f8 Update Changelog [ci skip] 2017-05-14 21:10:36 -03:00
Felipe Bergamo
6eb412efae Typo test doc 2017-04-24 18:38:49 -03:00
Alexander Grebennik
47077bf810 fix warnings about default value with new thor 2016-12-20 02:14:41 +03:00
Felipe Bergamo
9caae50339 Replace log_process_action to append_info_to_payload 2016-12-10 18:40:57 -02:00
213 changed files with 732 additions and 82 deletions

View File

@@ -2,9 +2,10 @@ language: ruby
rvm:
- 2.1.10
- 2.2.7
- 2.3.4
- 2.4.1
- 2.2.8
- 2.3.5
- 2.4.2
- 2.5.0
- ruby-head
gemfile:
@@ -17,7 +18,9 @@ matrix:
exclude:
- rvm: 2.1.10
gemfile: Gemfile
- rvm: 2.4.1
- rvm: 2.5.0
gemfile: gemfiles/Gemfile.rails-4.1-stable
- rvm: 2.4.2
gemfile: gemfiles/Gemfile.rails-4.1-stable
- rvm: ruby-head
gemfile: gemfiles/Gemfile.rails-4.1-stable
@@ -43,7 +46,9 @@ env:
- DEVISE_ORM=active_record
- DEVISE_ORM=mongoid
before_install: "rm ${BUNDLE_GEMFILE}.lock"
before_install:
- "rm ${BUNDLE_GEMFILE}.lock"
- gem update --system
before_script: "bundle update"

View File

@@ -1,4 +1,24 @@
### 4.3.0 - unreleased
### Unreleased
### 4.4.0 - 2017-12-29
* enhancements
* Add `frozen_string_literal` pragma comment to all Ruby files. (by @pat)
* Use `set_flash_method!` instead of `set_flash_method` in `Devise::OmniauthCallbacksController#failure`. (by @saichander17)
* Clarify how `store_location_for` modifies URIs. (by @olivierlacan)
* Move `failed_attempts` increment into its own function. by (@mobilutz)
* Add `autocomplete="email"` to email fields. by (@MikeRogers0)
* Add the ability to change the default migrations path introduced in Rails 5.0.3. (by @alexhifer)
* Delete unnecessary condition for helper method. (by @davydovanton)
* Support `id: :uuid` option for migrations. (by @filip373)
* bug fixes
* Fix syntax for MRI 2.5.0. (by @pat)
* Validations were being ignored on singup in the `Trackable#update_tracked_fields!` method. (by @AshleyFoster)
* Do not modify options for `#serializable_hash`. (by @guigs)
* Email confirmations were being sent on sign in/sign out for application using `mongoid` and `mongoid-paperclip` gems. This is because previously we were checking if a model is from Active Record by checking if the method `after_commit` was defined - since `mongoid` doesn' have one - but `mongoid-paperclip` gem does define one, which cause this issue. (by @fjg)
### 4.3.0 - 2017-05-14
* Enhancements
* Dependency support added for Rails 5.1.x.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec
@@ -14,9 +16,6 @@ gem "rails-controller-testing"
gem "responders", "~> 2.1"
# TODO: Remove this line when Rails 5.1.1 is released
gem "minitest", "< 5.10.2"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"

View File

@@ -10,7 +10,7 @@ GIT
PATH
remote: .
specs:
devise (4.3.0)
devise (4.4.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
@@ -176,7 +176,6 @@ DEPENDENCIES
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
minitest (< 5.10.2)
mocha (~> 1.1)
oauth2
omniauth (~> 1.3)
@@ -191,4 +190,4 @@ DEPENDENCIES
webrat (= 0.7.3)
BUNDLED WITH
1.14.6
1.15.3

19
ISSUE_TEMPLATE.md Normal file
View File

@@ -0,0 +1,19 @@
## Precheck
- Do not use the issues tracker for help or support, try Stack Overflow.
- For bugs, do a quick search and make sure the bug has not yet been reported
- Finally, be nice and have fun!
## Environment
- Ruby **[version]**
- Rails **[version]**
- Devise **[version]**
## Current behavior
Include code samples, errors, steps to reproduce the error and stacktraces if appropriate.
Will be even more helpful if you provide a sample application or a test case that reproduces the error.
## Expected behavior

View File

@@ -27,6 +27,50 @@ It's composed of 10 modules:
* [Validatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
* [Lockable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
## Table of Contents
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 orderedList:0 -->
- [Information](#information)
- [The Devise wiki](#the-devise-wiki)
- [Bug reports](#bug-reports)
- [StackOverflow and Mailing List](#stackoverflow-and-mailing-list)
- [RDocs](#rdocs)
- [Example applications](#example-applications)
- [Extensions](#extensions)
- [Contributing](#contributing)
- [Starting with Rails?](#starting-with-rails)
- [Getting started](#getting-started)
- [Controller filters and helpers](#controller-filters-and-helpers)
- [Configuring Models](#configuring-models)
- [Strong Parameters](#strong-parameters)
- [Configuring views](#configuring-views)
- [Configuring controllers](#configuring-controllers)
- [Configuring routes](#configuring-routes)
- [I18n](#i18n)
- [Test helpers](#test-helpers)
- [Controller tests](#controller-tests)
- [Integration tests](#integration-tests)
- [OmniAuth](#omniauth)
- [Configuring multiple models](#configuring-multiple-models)
- [Create a migration with the required fields](#create-a-migration-with-the-required-fields)
- [Inside your Admin model](#inside-your-admin-model)
- [Inside your routes](#inside-your-routes)
- [Inside your protected controller](#inside-your-protected-controller)
- [Inside your controllers and views](#inside-your-controllers-and-views)
- [ActiveJob Integration](#activejob-integration)
- [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs)
- [Other ORMs](#other-orms)
- [Additional information](#additional-information)
- [Heroku](#heroku)
- [Warden](#warden)
- [Contributors](#contributors)
- [License](#license)
<!-- /TOC -->
## Information
### The Devise wiki
@@ -126,7 +170,7 @@ Next, check the MODEL for any additional configuration options you might want to
Then run `rails db:migrate`
You should restart your application after changing Devise's configuration options. Otherwise, you will run into strange errors, for example, users being unable to login and route helpers being undefined.
You should restart your application after changing Devise's configuration options (this includes stopping spring). Otherwise, you will run into strange errors, for example, users being unable to login and route helpers being undefined.
### Controller filters and helpers
@@ -216,7 +260,21 @@ class ApplicationController < ActionController::Base
end
```
The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types. Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types:
```ruby
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, address_attributes: [:country, :state, :city, :area, :postal_code]])
end
end
```
Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
To permit simple scalar values for username and email, use this
@@ -374,6 +432,12 @@ end
This way, you tell Devise to use the scope `:user` when "/sign_in" is accessed. Notice `devise_scope` is also aliased as `as` in your router.
Please note: You will still need to add `devise_for` in your routes in order to use helper methods such as `current_user`.
```ruby
devise_for :users, skip: :all
```
### I18n
Devise uses flash messages with I18n, in conjunction with the flash keys :notice and :alert. To customize your app, you can set up your locale file:

View File

@@ -1,4 +1,5 @@
# encoding: UTF-8
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rake/testtask'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Devise::ConfirmationsController < DeviseController
# GET /resource/confirmation/new
def new

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Devise::OmniauthCallbacksController < DeviseController
prepend_before_action { request.env["devise.skip_timeout"] = true }
@@ -6,7 +8,7 @@ class Devise::OmniauthCallbacksController < DeviseController
end
def failure
set_flash_message :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
set_flash_message! :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
redirect_to after_omniauth_failure_path_for(resource_name)
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Devise::PasswordsController < DeviseController
prepend_before_action :require_no_authentication
# Render the #edit only if coming from a reset password email link

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Devise::RegistrationsController < DeviseController
prepend_before_action :require_no_authentication, only: [:new, :create, :cancel]
prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy]
@@ -5,7 +7,7 @@ class Devise::RegistrationsController < DeviseController
# GET /resource/sign_up
def new
build_resource({})
build_resource
yield resource if block_given?
respond_with resource
end
@@ -97,8 +99,8 @@ class Devise::RegistrationsController < DeviseController
# Build a devise resource passing in the session. Useful to move
# temporary session data to the newly created user.
def build_resource(hash=nil)
self.resource = resource_class.new_with_session(hash || {}, session)
def build_resource(hash = {})
self.resource = resource_class.new_with_session(hash, session)
end
# Signs in a user on sign up. You can overwrite this method in your own

View File

@@ -1,8 +1,10 @@
# frozen_string_literal: true
class Devise::SessionsController < DeviseController
prepend_before_action :require_no_authentication, only: [:new, :create]
prepend_before_action :allow_params_authentication!, only: :create
prepend_before_action :verify_signed_out_user, only: :destroy
prepend_before_action only: [:create, :destroy] { request.env["devise.skip_timeout"] = true }
prepend_before_action(only: [:create, :destroy]) { request.env["devise.skip_timeout"] = true }
# GET /resource/sign_in
def new

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Devise::UnlocksController < DeviseController
prepend_before_action :require_no_authentication

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# All Devise controllers are inherited from here.
class DeviseController < Devise.parent_controller.constantize
include Devise::Controllers::ScopedViews

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module DeviseHelper
# A simple way to show error messages for the current devise resource. If you need
# to customize this method, you can either overwrite it in your application helpers or

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
if defined?(ActionMailer)
class Devise::Mailer < Devise.parent_mailer.constantize
include Devise::Mailers::Helpers

View File

@@ -5,7 +5,7 @@
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>
<div class="actions">

View File

@@ -5,7 +5,7 @@
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="actions">

View File

@@ -5,7 +5,7 @@
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>

View File

@@ -5,7 +5,7 @@
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="field">

View File

@@ -3,7 +3,7 @@
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="field">

View File

@@ -5,7 +5,7 @@
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="actions">

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "devise/version"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec path: ".."
@@ -5,7 +7,7 @@ gemspec path: ".."
gem "rails", github: "rails/rails", branch: "4-1-stable"
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "rdoc", "~> 5.1"
group :test do
gem "omniauth-facebook"

View File

@@ -21,7 +21,7 @@ GIT
PATH
remote: ..
specs:
devise (4.3.0)
devise (4.4.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
@@ -162,10 +162,10 @@ DEPENDENCIES
omniauth-oauth2
omniauth-openid
rails!
rdoc
rdoc (~> 5.1)
sqlite3
test_after_commit
webrat (= 0.7.3)
BUNDLED WITH
1.14.6
1.15.3

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec path: ".."
@@ -5,7 +7,7 @@ gemspec path: ".."
gem "rails", github: "rails/rails", branch: "4-2-stable"
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "rdoc", "~> 5.1"
group :test do
gem "omniauth-facebook"

View File

@@ -57,7 +57,7 @@ GIT
PATH
remote: ..
specs:
devise (4.3.0)
devise (4.4.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
@@ -183,10 +183,10 @@ DEPENDENCIES
omniauth-oauth2
omniauth-openid
rails!
rdoc
rdoc (~> 5.1)
sqlite3
test_after_commit
webrat (= 0.7.3)
BUNDLED WITH
1.14.6
1.15.3

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec path: ".."
@@ -13,9 +15,6 @@ gem "rails-controller-testing"
gem "responders", "~> 2.1"
# TODO: Remove this line when Rails 5.0.3 is released
gem "minitest", "< 5.10.2"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"

View File

@@ -10,7 +10,7 @@ GIT
PATH
remote: ..
specs:
devise (4.3.0)
devise (4.4.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
@@ -175,7 +175,6 @@ PLATFORMS
DEPENDENCIES
activemodel-serializers-xml!
devise!
minitest (< 5.10.2)
mocha (~> 1.1)
omniauth
omniauth-facebook
@@ -190,4 +189,4 @@ DEPENDENCIES
webrat (= 0.7.3)
BUNDLED WITH
1.14.6
1.15.3

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
begin
require 'bundler/inline'
rescue LoadError => e

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails'
require 'active_support/core_ext/numeric/time'
require 'active_support/dependencies'
@@ -149,7 +151,7 @@ module Devise
mattr_accessor :timeout_in
@@timeout_in = 30.minutes
# Used to hash the password. Please generate one with rake secret.
# Used to hash the password. Please generate one with rails secret.
mattr_accessor :pepper
@@pepper = nil

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Controllers
# Those helpers are convenience methods added to ApplicationController.
@@ -10,6 +12,11 @@ module Devise
if respond_to?(:helper_method)
helper_method :warden, :signed_in?, :devise_controller?
end
def append_info_to_payload(payload)
super
payload[:status] ||= 401 unless payload[:exception]
end
end
module ClassMethods
@@ -76,11 +83,6 @@ module Devise
end
METHODS
end
def log_process_action(payload)
payload[:status] ||= 401 unless payload[:exception]
super
end
end
# Define authentication filters and accessor helpers based on mappings.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Controllers
# A module that may be optionally included in a controller in order

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Controllers
module ScopedViews

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Controllers
# Provide sign in and sign out functionality.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "uri"
module Devise
@@ -33,12 +35,9 @@ module Devise
#
def store_location_for(resource_or_scope, location)
session_key = stored_location_key_for(resource_or_scope)
uri = parse_uri(location)
if uri
path = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
path = [path, uri.fragment].compact.join('#')
session[session_key] = path
end
path = extract_path_from_location(location)
session[session_key] = path if path
end
private
@@ -53,6 +52,25 @@ module Devise
scope = Devise::Mapping.find_scope!(resource_or_scope)
"#{scope}_return_to"
end
def extract_path_from_location(location)
uri = parse_uri(location)
if uri
path = remove_domain_from_uri(uri)
path = add_fragment_back_to_path(uri, path)
path
end
end
def remove_domain_from_uri(uri)
[uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
end
def add_fragment_back_to_path(uri, path)
[path, uri.fragment].compact.join('#')
end
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Controllers
# Create url helpers to be used with resource/scope configuration. Acts as

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
# Checks the scope in the given environment and returns the associated failure app.
class Delegator

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'bcrypt'
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "action_controller/metal"
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Deny user access whenever their account is not active yet.
# We need this as hook to validate the user activity on each request
# and in case the user is using other strategies beside Devise ones.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
Warden::Manager.after_authentication do |record, warden, options|
clean_up_for_winning_strategy = !warden.winning_strategy.respond_to?(:clean_up_csrf?) ||
warden.winning_strategy.clean_up_csrf?

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Before logout hook to forget the user in the given scope, if it responds
# to forget_me! Also clear remember token to ensure the user won't be
# remembered again. Notice that we forget the user unless the record is not persisted.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# After each sign in, if resource responds to failed_attempts, sets it to 0
# This is only triggered when the user is explicitly set (with set_user)
Warden::Manager.after_set_user except: :fetch do |record, warden, options|

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Hooks
# A small warden proxy so we can remember, forget and

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
scope = options[:scope]
if record.respond_to?(:remember_me) && options[:store] != false &&

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Each time a record is set we check whether its session has already timed out
# or not, based on last request time. If so, the record is logged out and
# redirected to the sign in page. Also, each time the request comes and the

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# After each sign in, update sign in time, sign in count and sign in IP.
# This is only triggered when the user is explicitly set (with set_user)
# and on authentication. Retrieving the user from session (:fetch) does

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Mailers
module Helpers

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
# Responsible for handling devise mappings and routes configuration. Each
# resource configured by devise_for in routes is actually creating a mapping

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Models
class MissingAttribute < StandardError

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'active_model/version'
require 'devise/hooks/activatable'
require 'devise/hooks/csrf_cleaner'
@@ -102,7 +104,7 @@ module Devise
# and passing a new list of attributes you want to exempt. All attributes
# given to :except will simply add names to exempt to Devise internal list.
def serializable_hash(options = nil)
options ||= {}
options = options.try(:dup) || {}
options[:except] = Array(options[:except])
if options[:force_except]
@@ -256,7 +258,7 @@ module Devise
# end
#
# Finally, notice that Devise also queries for users in other scenarios
# besides authentication, for example when retrieving an user to send
# besides authentication, for example when retrieving a user to send
# an e-mail for password reset. In such cases, find_for_authentication
# is not called.
def find_for_authentication(tainted_conditions)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Models
# Confirmable is responsible to verify if an account is already confirmed to
@@ -46,7 +48,7 @@ module Devise
included do
before_create :generate_confirmation_token, if: :confirmation_required?
after_create :skip_reconfirmation_in_callback!, if: :send_confirmation_notification?
if respond_to?(:after_commit) # ActiveRecord
if defined?(ActiveRecord) && self.is_a?(ActiveRecord::Base) # ActiveRecord
after_commit :send_on_create_confirmation_instructions, on: :create, if: :send_confirmation_notification?
after_commit :send_reconfirmation_instructions, on: :update, if: :reconfirmation_required?
else # Mongoid

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/strategies/database_authenticatable'
module Devise
@@ -10,7 +12,7 @@ module Devise
# DatabaseAuthenticatable adds the following options to devise_for:
#
# * +pepper+: a random string used to provide a more secure hash. Use
# `rake secret` to generate new keys.
# `rails secret` to generate new keys.
#
# * +stretches+: the cost given to bcrypt.
#

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "devise/hooks/lockable"
module Devise
@@ -99,8 +101,7 @@ module Devise
if super && !access_locked?
true
else
self.failed_attempts ||= 0
self.failed_attempts += 1
increment_failed_attempts
if attempts_exceeded?
lock_access! unless access_locked?
else
@@ -109,6 +110,11 @@ module Devise
false
end
end
def increment_failed_attempts
self.failed_attempts ||= 0
self.failed_attempts += 1
end
def unauthenticated_message
# If set to paranoid mode, do not show the locked message because it

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/omniauth'
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Models

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Models
# Registerable is responsible for everything related to registering a new

View File

@@ -1,10 +1,12 @@
# frozen_string_literal: true
require 'devise/strategies/rememberable'
require 'devise/hooks/rememberable'
require 'devise/hooks/forgetable'
module Devise
module Models
# Rememberable manages generating and clearing token for remember the user
# Rememberable manages generating and clearing token for remembering the user
# from a saved cookie. Rememberable also has utility methods for dealing
# with serializing the user into the cookie and back from the cookie, trying
# to lookup the record based on the saved information.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/hooks/timeoutable'
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/hooks/trackable'
module Devise
@@ -30,7 +32,7 @@ module Devise
def update_tracked_fields!(request)
update_tracked_fields(request)
save(validate: false)
save
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Models
# Validatable creates all needed validations for a user email and password.
@@ -10,7 +12,7 @@ module Devise
# Validatable adds the following options to devise_for:
#
# * +email_regexp+: the regular expression used to validate e-mails;
# * +password_length+: a range expressing password length. Defaults to 8..72.
# * +password_length+: a range expressing password length. Defaults to 6..128.
#
module Validatable
# All validations used by this module.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'active_support/core_ext/object/with_options'
Devise.with_options model: true do |d|

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
begin
require "omniauth"
require "omniauth/version"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module OmniAuth
class StrategyNotFound < NameError

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module OmniAuth
module UrlHelpers

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'orm_adapter/adapters/active_record'
ActiveSupport.on_load(:active_record) do

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
ActiveSupport.on_load(:mongoid) do
require 'orm_adapter/adapters/mongoid'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
class ParameterFilter
def initialize(case_insensitive_keys, strip_whitespace_keys)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
# The +ParameterSanitizer+ deals with permitting specific parameters values
# for each +Devise+ scope in the application.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/rails/routes'
require 'devise/rails/warden_compat'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/core_ext/object/try"
require "active_support/core_ext/hash/slice"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Warden::Mixins::Common
def request
@request ||= ActionDispatch::Request.new(env)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/strategies/base'
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Strategies
# Base strategy for Devise. Responsible for verifying correct scope and mapping.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/strategies/authenticatable'
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/strategies/authenticatable'
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Test
# `Devise::Test::ControllerHelpers` provides a facility to test controllers

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
# Devise::Test::IntegrationHelpers is a helper module for facilitating
# authentication on Rails integration tests to bypass the required steps for

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module TestHelpers
def self.included(base)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/core_ext/module/delegation"
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'openssl'
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
VERSION = "4.3.0".freeze
VERSION = "4.4.0".freeze
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails/generators/active_record'
require 'generators/devise/orm_helpers'
@@ -6,14 +8,16 @@ module ActiveRecord
class DeviseGenerator < ActiveRecord::Generators::Base
argument :attributes, type: :array, default: [], banner: "field:type field:type"
class_option :primary_key_type, type: :string, desc: "The type for primary key"
include Devise::Generators::OrmHelpers
source_root File.expand_path("../templates", __FILE__)
def copy_devise_migration
if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
migration_template "migration_existing.rb", "db/migrate/add_devise_to_#{table_name}.rb", migration_version: migration_version
migration_template "migration_existing.rb", "#{migration_path}/add_devise_to_#{table_name}.rb", migration_version: migration_version
else
migration_template "migration.rb", "db/migrate/devise_create_#{table_name}.rb", migration_version: migration_version
migration_template "migration.rb", "#{migration_path}/devise_create_#{table_name}.rb", migration_version: migration_version
end
end
@@ -92,6 +96,15 @@ RUBY
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end
end
def primary_key_type
primary_key_string if rails5?
end
def primary_key_string
key_string = options[:primary_key_type]
", id: :#{key_string}" if key_string
end
end
end
end

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
def change
create_table :<%= table_name %> do |t|
create_table :<%= table_name %><%= primary_key_type %> do |t|
<%= migration_data -%>
<% attributes.each do |attribute| -%>

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
def self.up
change_table :<%= table_name %> do |t|

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails/generators/base'
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails/generators/named_base'
module Devise
@@ -8,7 +10,7 @@ module Devise
namespace "devise"
source_root File.expand_path("../templates", __FILE__)
desc "Generates a model with the given NAME (if one does not exist) with devise " <<
desc "Generates a model with the given NAME (if one does not exist) with devise " \
"configuration plus a migration file and devise routes."
hook_for :orm
@@ -16,7 +18,7 @@ module Devise
class_option :routes, desc: "Generate routes", type: :boolean, default: true
def add_devise_routes
devise_route = "devise_for :#{plural_name}"
devise_route = "devise_for :#{plural_name}".dup
devise_route << %Q(, class_name: "#{class_name}") if class_name.include?("::")
devise_route << %Q(, skip: :all) unless options.routes?
route devise_route

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails/generators/base'
require 'securerandom'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Generators
module OrmHelpers
@@ -23,7 +25,11 @@ CONTENT
end
def migration_path
@migration_path ||= File.join("db", "migrate")
if Rails.version >= '5.0.3'
db_migrate_path
else
@migration_path ||= File.join("db", "migrate")
end
end
def model_path

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails/generators/base'
module Devise
@@ -21,13 +23,6 @@ module Devise
public_task :copy_views
end
# TODO: Add this to Rails itself
module ClassMethods
def hide!
Rails::Generators.hide_namespace self.namespace
end
end
def copy_views
if options[:views]
options[:views].each do |directory|
@@ -139,7 +134,11 @@ module Devise
default: defined?(SimpleForm) ? "simple_form_for" : "form_for"
hook_for :markerb, desc: "Generate markerb instead of erb mail views",
default: defined?(Markerb) ? :markerb : :erb,
default: defined?(Markerb),
type: :boolean
hook_for :erb, desc: "Generate erb mail views",
default: !defined?(Markerb),
type: :boolean
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails/generators/named_base'
require 'generators/devise/orm_helpers'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class <%= @scope_prefix %>ConfirmationsController < Devise::ConfirmationsController
# GET /resource/confirmation/new
# def new

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class <%= @scope_prefix %>OmniauthCallbacksController < Devise::OmniauthCallbacksController
# You should configure your model like this:
# devise :omniauthable, omniauth_providers: [:twitter]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class <%= @scope_prefix %>PasswordsController < Devise::PasswordsController
# GET /resource/password/new
# def new

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class <%= @scope_prefix %>RegistrationsController < Devise::RegistrationsController
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class <%= @scope_prefix %>SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class <%= @scope_prefix %>UnlocksController < Devise::UnlocksController
# GET /resource/unlock/new
# def new

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'test_helper'
class CustomRegistrationsControllerTest < Devise::ControllerTestCase

Some files were not shown because too many files have changed in this diff Show More