devise-jdguyot 1.2.rc
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/CHANGELOG.rdoc +532 -0
- data/Gemfile +29 -0
- data/Gemfile.lock +152 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +353 -0
- data/Rakefile +36 -0
- data/TODO +4 -0
- data/app/controllers/devise/confirmations_controller.rb +33 -0
- data/app/controllers/devise/omniauth_callbacks_controller.rb +26 -0
- data/app/controllers/devise/passwords_controller.rb +41 -0
- data/app/controllers/devise/registrations_controller.rb +110 -0
- data/app/controllers/devise/sessions_controller.rb +25 -0
- data/app/controllers/devise/unlocks_controller.rb +34 -0
- data/app/helpers/devise_helper.rb +19 -0
- data/app/mailers/devise/mailer.rb +88 -0
- data/app/views/devise/confirmations/new.html.erb +12 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +16 -0
- data/app/views/devise/passwords/new.html.erb +12 -0
- data/app/views/devise/registrations/edit.html.erb +25 -0
- data/app/views/devise/registrations/new.html.erb +18 -0
- data/app/views/devise/sessions/new.html.erb +17 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +12 -0
- data/config/locales/en.yml +46 -0
- data/devise.gemspec +25 -0
- data/lib/devise/controllers/helpers.rb +227 -0
- data/lib/devise/controllers/internal_helpers.rb +119 -0
- data/lib/devise/controllers/scoped_views.rb +33 -0
- data/lib/devise/controllers/url_helpers.rb +39 -0
- data/lib/devise/encryptors/authlogic_sha512.rb +19 -0
- data/lib/devise/encryptors/base.rb +20 -0
- data/lib/devise/encryptors/clearance_sha1.rb +17 -0
- data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
- data/lib/devise/encryptors/sha1.rb +25 -0
- data/lib/devise/encryptors/sha512.rb +25 -0
- data/lib/devise/failure_app.rb +132 -0
- data/lib/devise/hooks/activatable.rb +11 -0
- data/lib/devise/hooks/forgetable.rb +12 -0
- data/lib/devise/hooks/rememberable.rb +48 -0
- data/lib/devise/hooks/timeoutable.rb +22 -0
- data/lib/devise/hooks/trackable.rb +9 -0
- data/lib/devise/mapping.rb +110 -0
- data/lib/devise/models/authenticatable.rb +146 -0
- data/lib/devise/models/confirmable.rb +160 -0
- data/lib/devise/models/database_authenticatable.rb +100 -0
- data/lib/devise/models/encryptable.rb +72 -0
- data/lib/devise/models/lockable.rb +169 -0
- data/lib/devise/models/omniauthable.rb +23 -0
- data/lib/devise/models/recoverable.rb +123 -0
- data/lib/devise/models/registerable.rb +21 -0
- data/lib/devise/models/rememberable.rb +130 -0
- data/lib/devise/models/timeoutable.rb +43 -0
- data/lib/devise/models/token_authenticatable.rb +72 -0
- data/lib/devise/models/trackable.rb +30 -0
- data/lib/devise/models/validatable.rb +65 -0
- data/lib/devise/models.rb +68 -0
- data/lib/devise/modules.rb +30 -0
- data/lib/devise/omniauth/config.rb +30 -0
- data/lib/devise/omniauth/test_helpers.rb +57 -0
- data/lib/devise/omniauth/url_helpers.rb +29 -0
- data/lib/devise/omniauth.rb +47 -0
- data/lib/devise/orm/active_record.rb +38 -0
- data/lib/devise/orm/mongoid.rb +31 -0
- data/lib/devise/path_checker.rb +18 -0
- data/lib/devise/rails/routes.rb +292 -0
- data/lib/devise/rails/warden_compat.rb +125 -0
- data/lib/devise/rails.rb +50 -0
- data/lib/devise/schema.rb +97 -0
- data/lib/devise/strategies/authenticatable.rb +150 -0
- data/lib/devise/strategies/base.rb +15 -0
- data/lib/devise/strategies/database_authenticatable.rb +21 -0
- data/lib/devise/strategies/rememberable.rb +51 -0
- data/lib/devise/strategies/token_authenticatable.rb +53 -0
- data/lib/devise/test_helpers.rb +100 -0
- data/lib/devise/version.rb +3 -0
- data/lib/devise.rb +381 -0
- data/lib/generators/active_record/devise_generator.rb +28 -0
- data/lib/generators/active_record/templates/migration.rb +31 -0
- data/lib/generators/devise/devise_generator.rb +17 -0
- data/lib/generators/devise/install_generator.rb +24 -0
- data/lib/generators/devise/orm_helpers.rb +23 -0
- data/lib/generators/devise/views_generator.rb +106 -0
- data/lib/generators/mongoid/devise_generator.rb +17 -0
- data/lib/generators/templates/README +25 -0
- data/lib/generators/templates/devise.rb +186 -0
- data/test/controllers/helpers_test.rb +237 -0
- data/test/controllers/internal_helpers_test.rb +72 -0
- data/test/controllers/url_helpers_test.rb +59 -0
- data/test/devise_test.rb +65 -0
- data/test/encryptors_test.rb +30 -0
- data/test/failure_app_test.rb +187 -0
- data/test/generators/active_record_generator_test.rb +24 -0
- data/test/generators/install_generator_test.rb +13 -0
- data/test/generators/mongoid_generator_test.rb +22 -0
- data/test/generators/views_generator_test.rb +35 -0
- data/test/indifferent_hash.rb +33 -0
- data/test/integration/authenticatable_test.rb +447 -0
- data/test/integration/confirmable_test.rb +104 -0
- data/test/integration/database_authenticatable_test.rb +60 -0
- data/test/integration/http_authenticatable_test.rb +74 -0
- data/test/integration/lockable_test.rb +109 -0
- data/test/integration/omniauthable_test.rb +107 -0
- data/test/integration/recoverable_test.rb +160 -0
- data/test/integration/registerable_test.rb +179 -0
- data/test/integration/rememberable_test.rb +180 -0
- data/test/integration/timeoutable_test.rb +89 -0
- data/test/integration/token_authenticatable_test.rb +99 -0
- data/test/integration/trackable_test.rb +64 -0
- data/test/mailers/confirmation_instructions_test.rb +84 -0
- data/test/mailers/reset_password_instructions_test.rb +72 -0
- data/test/mailers/unlock_instructions_test.rb +66 -0
- data/test/mapping_test.rb +119 -0
- data/test/models/confirmable_test.rb +221 -0
- data/test/models/database_authenticatable_test.rb +98 -0
- data/test/models/encryptable_test.rb +65 -0
- data/test/models/lockable_test.rb +204 -0
- data/test/models/recoverable_test.rb +190 -0
- data/test/models/rememberable_test.rb +279 -0
- data/test/models/timeoutable_test.rb +28 -0
- data/test/models/token_authenticatable_test.rb +37 -0
- data/test/models/trackable_test.rb +5 -0
- data/test/models/validatable_test.rb +99 -0
- data/test/models_test.rb +84 -0
- data/test/omniauth/url_helpers_test.rb +47 -0
- data/test/orm/active_record.rb +9 -0
- data/test/orm/mongoid.rb +11 -0
- data/test/rails_app/Rakefile +10 -0
- data/test/rails_app/app/active_record/admin.rb +6 -0
- data/test/rails_app/app/active_record/shim.rb +2 -0
- data/test/rails_app/app/active_record/user.rb +8 -0
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
- data/test/rails_app/app/controllers/admins_controller.rb +6 -0
- data/test/rails_app/app/controllers/application_controller.rb +8 -0
- data/test/rails_app/app/controllers/home_controller.rb +16 -0
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +7 -0
- data/test/rails_app/app/controllers/users_controller.rb +18 -0
- data/test/rails_app/app/helpers/application_helper.rb +3 -0
- data/test/rails_app/app/mongoid/admin.rb +9 -0
- data/test/rails_app/app/mongoid/shim.rb +29 -0
- data/test/rails_app/app/mongoid/user.rb +10 -0
- data/test/rails_app/app/views/admins/index.html.erb +1 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
- data/test/rails_app/app/views/home/index.html.erb +1 -0
- data/test/rails_app/app/views/home/private.html.erb +1 -0
- data/test/rails_app/app/views/layouts/application.html.erb +24 -0
- data/test/rails_app/app/views/users/index.html.erb +1 -0
- data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
- data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
- data/test/rails_app/config/application.rb +40 -0
- data/test/rails_app/config/boot.rb +13 -0
- data/test/rails_app/config/database.yml +18 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +19 -0
- data/test/rails_app/config/environments/production.rb +33 -0
- data/test/rails_app/config/environments/test.rb +33 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/devise.rb +176 -0
- data/test/rails_app/config/initializers/inflections.rb +2 -0
- data/test/rails_app/config/initializers/secret_token.rb +2 -0
- data/test/rails_app/config/routes.rb +55 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +31 -0
- data/test/rails_app/db/schema.rb +52 -0
- data/test/rails_app/lib/shared_admin.rb +9 -0
- data/test/rails_app/lib/shared_user.rb +23 -0
- data/test/rails_app/public/404.html +26 -0
- data/test/rails_app/public/422.html +26 -0
- data/test/rails_app/public/500.html +26 -0
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_app/script/rails +10 -0
- data/test/routes_test.rb +179 -0
- data/test/support/assertions.rb +24 -0
- data/test/support/helpers.rb +60 -0
- data/test/support/integration.rb +88 -0
- data/test/support/locale/en.yml +4 -0
- data/test/support/webrat/integrations/rails.rb +24 -0
- data/test/test_helper.rb +29 -0
- data/test/test_helpers_test.rb +118 -0
- metadata +388 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
class Devise::RegistrationsController < ApplicationController
|
2
|
+
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
|
3
|
+
prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
|
4
|
+
include Devise::Controllers::InternalHelpers
|
5
|
+
|
6
|
+
# GET /resource/sign_up
|
7
|
+
def new
|
8
|
+
build_resource({})
|
9
|
+
render_with_scope :new
|
10
|
+
end
|
11
|
+
|
12
|
+
# POST /resource
|
13
|
+
def create
|
14
|
+
build_resource
|
15
|
+
|
16
|
+
if resource.save
|
17
|
+
if resource.active?
|
18
|
+
set_flash_message :notice, :signed_up
|
19
|
+
sign_in_and_redirect(resource_name, resource)
|
20
|
+
else
|
21
|
+
set_flash_message :notice, :inactive_signed_up, :reason => resource.inactive_message.to_s
|
22
|
+
expire_session_data_after_sign_in!
|
23
|
+
redirect_to after_inactive_sign_up_path_for(resource)
|
24
|
+
end
|
25
|
+
else
|
26
|
+
clean_up_passwords(resource)
|
27
|
+
render_with_scope :new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# GET /resource/edit
|
32
|
+
def edit
|
33
|
+
render_with_scope :edit
|
34
|
+
end
|
35
|
+
|
36
|
+
# PUT /resource
|
37
|
+
def update
|
38
|
+
if resource.update_with_password(params[resource_name])
|
39
|
+
set_flash_message :notice, :updated
|
40
|
+
sign_in resource_name, resource, :bypass => true
|
41
|
+
redirect_to after_update_path_for(resource)
|
42
|
+
else
|
43
|
+
clean_up_passwords(resource)
|
44
|
+
render_with_scope :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# DELETE /resource
|
49
|
+
def destroy
|
50
|
+
resource.destroy
|
51
|
+
sign_out_and_redirect(self.resource)
|
52
|
+
set_flash_message :notice, :destroyed
|
53
|
+
end
|
54
|
+
|
55
|
+
# GET /resource/cancel
|
56
|
+
# Forces the session data which is usually expired after sign
|
57
|
+
# in to be expired now. This is useful if the user wants to
|
58
|
+
# cancel oauth signing in/up in the middle of the process,
|
59
|
+
# removing all OAuth session data.
|
60
|
+
def cancel
|
61
|
+
expire_session_data_after_sign_in!
|
62
|
+
redirect_to new_registration_path(resource_name)
|
63
|
+
end
|
64
|
+
|
65
|
+
protected
|
66
|
+
|
67
|
+
# Build a devise resource passing in the session. Useful to move
|
68
|
+
# temporary session data to the newly created user.
|
69
|
+
def build_resource(hash=nil)
|
70
|
+
hash ||= params[resource_name] || {}
|
71
|
+
self.resource = resource_class.new_with_session(hash, session)
|
72
|
+
end
|
73
|
+
|
74
|
+
# The path used after sign up. You need to overwrite this method
|
75
|
+
# in your own RegistrationsController.
|
76
|
+
def after_sign_up_path_for(resource)
|
77
|
+
after_sign_in_path_for(resource)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Overwrite redirect_for_sign_in so it takes uses after_sign_up_path_for.
|
81
|
+
def redirect_for_sign_in(scope, resource) #:nodoc:
|
82
|
+
redirect_to stored_location_for(scope) || after_sign_up_path_for(resource)
|
83
|
+
end
|
84
|
+
|
85
|
+
# The path used after sign up for inactive accounts. You need to overwrite
|
86
|
+
# this method in your own RegistrationsController.
|
87
|
+
def after_inactive_sign_up_path_for(resource)
|
88
|
+
root_path
|
89
|
+
end
|
90
|
+
|
91
|
+
# The default url to be used after updating a resource. You need to overwrite
|
92
|
+
# this method in your own RegistrationsController.
|
93
|
+
def after_update_path_for(resource)
|
94
|
+
if defined?(super)
|
95
|
+
ActiveSupport::Deprecation.warn "Defining after_update_path_for in ApplicationController " <<
|
96
|
+
"is deprecated. Please add a RegistrationsController to your application and define it there."
|
97
|
+
super
|
98
|
+
else
|
99
|
+
after_sign_in_path_for(resource)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Authenticates the current scope and gets a copy of the current resource.
|
104
|
+
# We need to use a copy because we don't want actions like update changing
|
105
|
+
# the current user in place.
|
106
|
+
def authenticate_scope!
|
107
|
+
send(:"authenticate_#{resource_name}!", true)
|
108
|
+
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Devise::SessionsController < ApplicationController
|
2
|
+
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
|
3
|
+
include Devise::Controllers::InternalHelpers
|
4
|
+
|
5
|
+
# GET /resource/sign_in
|
6
|
+
def new
|
7
|
+
clean_up_passwords(build_resource)
|
8
|
+
render_with_scope :new
|
9
|
+
end
|
10
|
+
|
11
|
+
# POST /resource/sign_in
|
12
|
+
def create
|
13
|
+
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
|
14
|
+
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
15
|
+
sign_in(resource_name, resource)
|
16
|
+
respond_with resource, :location => redirect_location(resource_name, resource)
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /resource/sign_out
|
20
|
+
def destroy
|
21
|
+
signed_in = signed_in?(resource_name)
|
22
|
+
sign_out_and_redirect(resource_name)
|
23
|
+
set_flash_message :notice, :signed_out if signed_in
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Devise::UnlocksController < ApplicationController
|
2
|
+
prepend_before_filter :require_no_authentication
|
3
|
+
include Devise::Controllers::InternalHelpers
|
4
|
+
|
5
|
+
# GET /resource/unlock/new
|
6
|
+
def new
|
7
|
+
build_resource({})
|
8
|
+
render_with_scope :new
|
9
|
+
end
|
10
|
+
|
11
|
+
# POST /resource/unlock
|
12
|
+
def create
|
13
|
+
self.resource = resource_class.send_unlock_instructions(params[resource_name])
|
14
|
+
|
15
|
+
if resource.errors.empty?
|
16
|
+
set_flash_message :notice, :send_instructions
|
17
|
+
redirect_to new_session_path(resource_name)
|
18
|
+
else
|
19
|
+
render_with_scope :new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# GET /resource/unlock?unlock_token=abcdef
|
24
|
+
def show
|
25
|
+
self.resource = resource_class.unlock_access_by_token(params[:unlock_token])
|
26
|
+
|
27
|
+
if resource.errors.empty?
|
28
|
+
set_flash_message :notice, :unlocked
|
29
|
+
sign_in_and_redirect(resource_name, resource)
|
30
|
+
else
|
31
|
+
render_with_scope :new
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module DeviseHelper
|
2
|
+
def devise_error_messages!
|
3
|
+
return "" if resource.errors.empty?
|
4
|
+
|
5
|
+
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
|
6
|
+
sentence = I18n.t("errors.messages.not_saved",
|
7
|
+
:count => resource.errors.count,
|
8
|
+
:resource => resource_name)
|
9
|
+
|
10
|
+
html = <<-HTML
|
11
|
+
<div id="error_explanation">
|
12
|
+
<h2>#{sentence}</h2>
|
13
|
+
<ul>#{messages}</ul>
|
14
|
+
</div>
|
15
|
+
HTML
|
16
|
+
|
17
|
+
html.html_safe
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
class Devise::Mailer < ::ActionMailer::Base
|
2
|
+
include Devise::Controllers::ScopedViews
|
3
|
+
attr_reader :scope_name, :resource
|
4
|
+
|
5
|
+
def confirmation_instructions(record)
|
6
|
+
setup_mail(record, :confirmation_instructions)
|
7
|
+
end
|
8
|
+
|
9
|
+
def reset_password_instructions(record)
|
10
|
+
setup_mail(record, :reset_password_instructions)
|
11
|
+
end
|
12
|
+
|
13
|
+
def unlock_instructions(record)
|
14
|
+
setup_mail(record, :unlock_instructions)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
# Configure default email options
|
20
|
+
def setup_mail(record, action)
|
21
|
+
initialize_from_record(record)
|
22
|
+
mail headers_for(action)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize_from_record(record)
|
26
|
+
@scope_name = Devise::Mapping.find_scope!(record)
|
27
|
+
@resource = instance_variable_set("@#{devise_mapping.name}", record)
|
28
|
+
end
|
29
|
+
|
30
|
+
def devise_mapping
|
31
|
+
@devise_mapping ||= Devise.mappings[scope_name]
|
32
|
+
end
|
33
|
+
|
34
|
+
def headers_for(action)
|
35
|
+
headers = {
|
36
|
+
:subject => translate(devise_mapping, action),
|
37
|
+
:from => mailer_sender(devise_mapping),
|
38
|
+
:to => resource.email,
|
39
|
+
:template_path => template_paths
|
40
|
+
}
|
41
|
+
|
42
|
+
if resource.respond_to?(:headers_for)
|
43
|
+
headers.merge!(resource.headers_for(action))
|
44
|
+
end
|
45
|
+
|
46
|
+
unless headers.key?(:reply_to)
|
47
|
+
headers[:reply_to] = headers[:from]
|
48
|
+
end
|
49
|
+
|
50
|
+
headers
|
51
|
+
end
|
52
|
+
|
53
|
+
def mailer_sender(mapping)
|
54
|
+
if Devise.mailer_sender.is_a?(Proc)
|
55
|
+
Devise.mailer_sender.call(mapping.name)
|
56
|
+
else
|
57
|
+
Devise.mailer_sender
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def template_paths
|
62
|
+
template_path = [self.class.mailer_name]
|
63
|
+
template_path.unshift "#{@devise_mapping.scoped_path}/mailer" if self.class.scoped_views?
|
64
|
+
template_path
|
65
|
+
end
|
66
|
+
|
67
|
+
# Setup a subject doing an I18n lookup. At first, it attemps to set a subject
|
68
|
+
# based on the current mapping:
|
69
|
+
#
|
70
|
+
# en:
|
71
|
+
# devise:
|
72
|
+
# mailer:
|
73
|
+
# confirmation_instructions:
|
74
|
+
# user_subject: '...'
|
75
|
+
#
|
76
|
+
# If one does not exist, it fallbacks to ActionMailer default:
|
77
|
+
#
|
78
|
+
# en:
|
79
|
+
# devise:
|
80
|
+
# mailer:
|
81
|
+
# confirmation_instructions:
|
82
|
+
# subject: '...'
|
83
|
+
#
|
84
|
+
def translate(mapping, key)
|
85
|
+
I18n.t(:"#{mapping.name}_subject", :scope => [:devise, :mailer, key],
|
86
|
+
:default => [:subject, key.to_s.humanize])
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<h2>Resend confirmation instructions</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<p><%= f.label :email %><br />
|
7
|
+
<%= f.email_field :email %></p>
|
8
|
+
|
9
|
+
<p><%= f.submit "Resend confirmation instructions" %></p>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= render :partial => "devise/shared/links" %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<p>Hello <%= @resource.email %>!</p>
|
2
|
+
|
3
|
+
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
|
4
|
+
|
5
|
+
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
|
6
|
+
|
7
|
+
<p>If you didn't request this, please ignore this email.</p>
|
8
|
+
<p>Your password won't change until you access the link above and create a new one.</p>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>Hello <%= @resource.email %>!</p>
|
2
|
+
|
3
|
+
<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
|
4
|
+
|
5
|
+
<p>Click the link below to unlock your account:</p>
|
6
|
+
|
7
|
+
<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<h2>Change your password</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
<%= f.hidden_field :reset_password_token %>
|
6
|
+
|
7
|
+
<p><%= f.label :password, "New password" %><br />
|
8
|
+
<%= f.password_field :password %></p>
|
9
|
+
|
10
|
+
<p><%= f.label :password_confirmation, "Confirm new password" %><br />
|
11
|
+
<%= f.password_field :password_confirmation %></p>
|
12
|
+
|
13
|
+
<p><%= f.submit "Change my password" %></p>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= render :partial => "devise/shared/links" %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<h2>Forgot your password?</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<p><%= f.label :email %><br />
|
7
|
+
<%= f.email_field :email %></p>
|
8
|
+
|
9
|
+
<p><%= f.submit "Send me reset password instructions" %></p>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= render :partial => "devise/shared/links" %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<p><%= f.label :email %><br />
|
7
|
+
<%= f.email_field :email %></p>
|
8
|
+
|
9
|
+
<p><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
10
|
+
<%= f.password_field :password %></p>
|
11
|
+
|
12
|
+
<p><%= f.label :password_confirmation %><br />
|
13
|
+
<%= f.password_field :password_confirmation %></p>
|
14
|
+
|
15
|
+
<p><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
16
|
+
<%= f.password_field :current_password %></p>
|
17
|
+
|
18
|
+
<p><%= f.submit "Update" %></p>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<h3>Cancel my account</h3>
|
22
|
+
|
23
|
+
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
|
24
|
+
|
25
|
+
<%= link_to "Back", :back %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<h2>Sign up</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<p><%= f.label :email %><br />
|
7
|
+
<%= f.email_field :email %></p>
|
8
|
+
|
9
|
+
<p><%= f.label :password %><br />
|
10
|
+
<%= f.password_field :password %></p>
|
11
|
+
|
12
|
+
<p><%= f.label :password_confirmation %><br />
|
13
|
+
<%= f.password_field :password_confirmation %></p>
|
14
|
+
|
15
|
+
<p><%= f.submit "Sign up" %></p>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<%= render :partial => "devise/shared/links" %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<h2>Sign in</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
4
|
+
<p><%= f.label :email %><br />
|
5
|
+
<%= f.email_field :email %></p>
|
6
|
+
|
7
|
+
<p><%= f.label :password %><br />
|
8
|
+
<%= f.password_field :password %></p>
|
9
|
+
|
10
|
+
<% if devise_mapping.rememberable? -%>
|
11
|
+
<p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
|
12
|
+
<% end -%>
|
13
|
+
|
14
|
+
<p><%= f.submit "Sign in" %></p>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%= render :partial => "devise/shared/links" %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%- if controller_name != 'sessions' %>
|
2
|
+
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
3
|
+
<% end -%>
|
4
|
+
|
5
|
+
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
6
|
+
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
10
|
+
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
11
|
+
<% end -%>
|
12
|
+
|
13
|
+
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
14
|
+
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
15
|
+
<% end -%>
|
16
|
+
|
17
|
+
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
18
|
+
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
19
|
+
<% end -%>
|
20
|
+
|
21
|
+
<%- if devise_mapping.omniauthable? %>
|
22
|
+
<%- resource_class.omniauth_providers.each do |provider| %>
|
23
|
+
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
|
24
|
+
<% end -%>
|
25
|
+
<% end -%>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<h2>Resend unlock instructions</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<p><%= f.label :email %><br />
|
7
|
+
<%= f.email_field :email %></p>
|
8
|
+
|
9
|
+
<p><%= f.submit "Resend unlock instructions" %></p>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= render :partial => "devise/shared/links" %>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
en:
|
2
|
+
errors:
|
3
|
+
messages:
|
4
|
+
not_found: "not found"
|
5
|
+
already_confirmed: "was already confirmed, please try signing in"
|
6
|
+
not_locked: "was not locked"
|
7
|
+
not_saved:
|
8
|
+
one: "1 error prohibited this %{resource} from being saved:"
|
9
|
+
other: "%{count} errors prohibited this %{resource} from being saved:"
|
10
|
+
|
11
|
+
devise:
|
12
|
+
failure:
|
13
|
+
unauthenticated: 'You need to sign in or sign up before continuing.'
|
14
|
+
unconfirmed: 'You have to confirm your account before continuing.'
|
15
|
+
locked: 'Your account is locked.'
|
16
|
+
invalid: 'Invalid email or password.'
|
17
|
+
invalid_token: 'Invalid authentication token.'
|
18
|
+
timeout: 'Your session expired, please sign in again to continue.'
|
19
|
+
inactive: 'Your account was not activated yet.'
|
20
|
+
sessions:
|
21
|
+
signed_in: 'Signed in successfully.'
|
22
|
+
signed_out: 'Signed out successfully.'
|
23
|
+
passwords:
|
24
|
+
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
|
25
|
+
updated: 'Your password was changed successfully. You are now signed in.'
|
26
|
+
confirmations:
|
27
|
+
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
28
|
+
confirmed: 'Your account was successfully confirmed. You are now signed in.'
|
29
|
+
registrations:
|
30
|
+
signed_up: 'Welcome! You have signed up successfully.'
|
31
|
+
inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
|
32
|
+
updated: 'You updated your account successfully.'
|
33
|
+
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
|
34
|
+
unlocks:
|
35
|
+
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
36
|
+
unlocked: 'Your account was successfully unlocked. You are now signed in.'
|
37
|
+
omniauth_callbacks:
|
38
|
+
success: 'Successfully authorized from %{kind} account.'
|
39
|
+
failure: 'Could not authorize you from %{kind} because "%{reason}".'
|
40
|
+
mailer:
|
41
|
+
confirmation_instructions:
|
42
|
+
subject: 'Confirmation instructions'
|
43
|
+
reset_password_instructions:
|
44
|
+
subject: 'Reset password instructions'
|
45
|
+
unlock_instructions:
|
46
|
+
subject: 'Unlock Instructions'
|
data/devise.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "devise/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "devise-jdguyot"
|
7
|
+
s.version = Devise::VERSION.dup
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.summary = "Flexible authentication solution for Rails with Warden"
|
10
|
+
s.email = "contact@plataformatec.com.br"
|
11
|
+
s.homepage = "http://github.com/capitaine-train/devise"
|
12
|
+
s.description = "Flexible authentication solution for Rails with Warden"
|
13
|
+
s.authors = ['José Valim', 'Carlos Antônio']
|
14
|
+
|
15
|
+
s.rubyforge_project = "devise"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency("warden", "~> 1.0.3")
|
23
|
+
s.add_dependency("orm_adapter", "~> 0.0.3")
|
24
|
+
s.add_dependency("bcrypt-ruby", "~> 2.1.2")
|
25
|
+
end
|