devise_password_changable 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem "rails"
6
+ gem "devise"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "shoulda", ">= 0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.6.0"
14
+ # gem "rcov", ">= 0"
15
+ end
@@ -0,0 +1,89 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.7)
6
+ actionpack (= 3.0.7)
7
+ mail (~> 2.2.15)
8
+ actionpack (3.0.7)
9
+ activemodel (= 3.0.7)
10
+ activesupport (= 3.0.7)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.5.0)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.14)
16
+ rack-test (~> 0.5.7)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.7)
19
+ activesupport (= 3.0.7)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.5.0)
22
+ activerecord (3.0.7)
23
+ activemodel (= 3.0.7)
24
+ activesupport (= 3.0.7)
25
+ arel (~> 2.0.2)
26
+ tzinfo (~> 0.3.23)
27
+ activeresource (3.0.7)
28
+ activemodel (= 3.0.7)
29
+ activesupport (= 3.0.7)
30
+ activesupport (3.0.7)
31
+ arel (2.0.9)
32
+ bcrypt-ruby (2.1.4)
33
+ builder (2.1.2)
34
+ devise (1.3.4)
35
+ bcrypt-ruby (~> 2.1.2)
36
+ orm_adapter (~> 0.0.3)
37
+ warden (~> 1.0.3)
38
+ erubis (2.6.6)
39
+ abstract (>= 1.0.0)
40
+ git (1.2.5)
41
+ i18n (0.5.0)
42
+ jeweler (1.6.0)
43
+ bundler (~> 1.0.0)
44
+ git (>= 1.2.5)
45
+ rake
46
+ mail (2.2.19)
47
+ activesupport (>= 2.3.6)
48
+ i18n (>= 0.4.0)
49
+ mime-types (~> 1.16)
50
+ treetop (~> 1.4.8)
51
+ mime-types (1.16)
52
+ orm_adapter (0.0.4)
53
+ polyglot (0.3.1)
54
+ rack (1.2.2)
55
+ rack-mount (0.6.14)
56
+ rack (>= 1.0.0)
57
+ rack-test (0.5.7)
58
+ rack (>= 1.0)
59
+ rails (3.0.7)
60
+ actionmailer (= 3.0.7)
61
+ actionpack (= 3.0.7)
62
+ activerecord (= 3.0.7)
63
+ activeresource (= 3.0.7)
64
+ activesupport (= 3.0.7)
65
+ bundler (~> 1.0)
66
+ railties (= 3.0.7)
67
+ railties (3.0.7)
68
+ actionpack (= 3.0.7)
69
+ activesupport (= 3.0.7)
70
+ rake (>= 0.8.7)
71
+ thor (~> 0.14.4)
72
+ rake (0.8.7)
73
+ shoulda (2.11.3)
74
+ thor (0.14.6)
75
+ treetop (1.4.9)
76
+ polyglot (>= 0.3.1)
77
+ tzinfo (0.3.27)
78
+ warden (1.0.4)
79
+ rack (>= 1.0)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ bundler (~> 1.0.0)
86
+ devise
87
+ jeweler (~> 1.6.0)
88
+ rails
89
+ shoulda
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Szymon Fiedler
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ = Devise Password Changable
2
+
3
+ Extension for devise to provide password change without using registerable module.
4
+
5
+ == Installation for Rails 3
6
+
7
+ Add line below to your Gemfile:
8
+
9
+ gem 'devise_password_changable'
10
+
11
+ and run _bundle_.
12
+
13
+ In your custom _User_ model in devise block add:
14
+
15
+ password_changable
16
+
17
+ so, it'll look like this:
18
+
19
+ devise :database_authenticatable, :recoverable, :trackable, :password_changable
20
+
21
+ Now, password change is available to your users, so they can visit e.g. path yourapp.com/users/password_change and change their password.
22
+
23
+ == Customizing
24
+
25
+ You can customize view "devise-way" if you are using _scoped_views_, by creating your own, customized show view file:
26
+
27
+ app
28
+ views
29
+ users
30
+ change_passwords
31
+ show.html.erb
32
+
33
+ == ToDo
34
+
35
+ Write some tests with test_app...
36
+
37
+ == Contributing to devise_password_changable
38
+
39
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
40
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
41
+ * Fork the project
42
+ * Start a feature/bugfix branch
43
+ * Commit and push until you are happy with your contribution
44
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
45
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
46
+
47
+ == Copyright
48
+
49
+ Copyright (c) 2011 Szymon Fiedler. See LICENSE.txt for
50
+ further details.
51
+
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "devise_password_changable"
18
+ gem.homepage = "http://github.com/fidel/devise_password_changable"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Extension for devise to provide password change.}
21
+ gem.description = %Q{Extension for devise to provide password change without using registerable.}
22
+ gem.email = "fidelski@gmail.com"
23
+ gem.authors = ["Szymon Fiedler"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ # require 'rcov/rcovtask'
36
+ # Rcov::RcovTask.new do |test|
37
+ # test.libs << 'test'
38
+ # test.pattern = 'test/**/test_*.rb'
39
+ # test.verbose = true
40
+ # test.rcov_opts << '--exclude "gems/*"'
41
+ # end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "devise_password_changable #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,40 @@
1
+ class Devise::ChangePasswordsController < ApplicationController
2
+
3
+ respond_to :html
4
+
5
+ prepend_before_filter :authenticate_scope!, :only => [:show, :update]
6
+ include Devise::Controllers::InternalHelpers
7
+
8
+ def show
9
+ render_with_scope :show
10
+ end
11
+
12
+ def update
13
+
14
+ if resource.update_with_password(params[resource_name])
15
+ set_flash_message :notice, :updated
16
+ respond_with resource, :location => after_update_path_for(resource)
17
+ else
18
+ clean_up_passwords(resource)
19
+ render_with_scope :show
20
+ end
21
+ end
22
+
23
+ protected
24
+
25
+ def after_update_path_for(resource)
26
+ if defined?(super)
27
+ ActiveSupport::Deprecation.warn "Defining after_update_path_for in ApplicationController " <<
28
+ "is deprecated. Please add a ChangePasswordsController to your application and define it there."
29
+ super
30
+ else
31
+ after_sign_in_path_for(resource)
32
+ end
33
+ end
34
+
35
+ def authenticate_scope!
36
+ send(:"authenticate_#{resource_name}!")
37
+ self.resource = send(:"current_#{resource_name}")
38
+ end
39
+
40
+ end
@@ -0,0 +1,16 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => [resource_name, :password_change], :html => { :method => :put }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <p><%= f.label :current_password, "Current password" %><br />
7
+ <%= f.password_field :current_password %></p>
8
+
9
+ <p><%= f.label :password, "New password" %><br />
10
+ <%= f.password_field :password %></p>
11
+
12
+ <p><%= f.label :password_confirmation, "Confirm new password" %><br />
13
+ <%= f.password_field :password_confirmation %></p>
14
+
15
+ <p><%= f.submit "Change my password" %></p>
16
+ <% end %>
@@ -0,0 +1,4 @@
1
+ en:
2
+ devise:
3
+ change_passwords:
4
+ updated: Your new password is saved
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{devise_password_changable}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Szymon Fiedler"]
12
+ s.date = %q{2011-05-12}
13
+ s.description = %q{Extension for devise to provide password change without using registerable.}
14
+ s.email = %q{fidelski@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "app/controllers/devise/change_passwords_controller.rb",
28
+ "app/views/devise/change_passwords/show.html.erb",
29
+ "config/locales/en.yml",
30
+ "devise_password_changable.gemspec",
31
+ "lib/devise_password_changable.rb",
32
+ "lib/devise_password_changable/controllers/helpers.rb",
33
+ "lib/devise_password_changable/models/password_changable.rb",
34
+ "lib/devise_password_changable/rails.rb",
35
+ "lib/devise_password_changable/routes.rb",
36
+ "test/helper.rb",
37
+ "test/test_devise_password_changable.rb"
38
+ ]
39
+ s.homepage = %q{http://github.com/fidel/devise_password_changable}
40
+ s.licenses = ["MIT"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = %q{1.7.1}
43
+ s.summary = %q{Extension for devise to provide password change.}
44
+
45
+ if s.respond_to? :specification_version then
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
+ s.add_runtime_dependency(%q<rails>, [">= 0"])
50
+ s.add_runtime_dependency(%q<devise>, [">= 0"])
51
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
52
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
53
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
54
+ else
55
+ s.add_dependency(%q<rails>, [">= 0"])
56
+ s.add_dependency(%q<devise>, [">= 0"])
57
+ s.add_dependency(%q<shoulda>, [">= 0"])
58
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<rails>, [">= 0"])
63
+ s.add_dependency(%q<devise>, [">= 0"])
64
+ s.add_dependency(%q<shoulda>, [">= 0"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
67
+ end
68
+ end
69
+
@@ -0,0 +1,15 @@
1
+ require 'active_support/core_ext/integer'
2
+ require 'active_support/ordered_hash'
3
+ require 'active_support/concern'
4
+ require 'devise'
5
+
6
+ module DevisePasswordChangable
7
+ module Controllers
8
+ autoload :Helpers, 'devise_password_changable/controllers/helpers'
9
+ end
10
+ end
11
+
12
+ require 'devise_password_changable/rails'
13
+ require 'devise_password_changable/routes'
14
+
15
+ Devise.add_module :password_changable, :controller => :change_passwords, :model => 'devise_password_changable/models/password_changable', :route => :password_change
@@ -0,0 +1,7 @@
1
+ module DevisePasswordChangable
2
+ module Controllers
3
+ module Helpers
4
+ extend ActiveSupport::Concern
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Devise
2
+ module Models
3
+ module PasswordChangable
4
+ extend ActiveSupport::Concern
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module DevisePasswordChangable
2
+ class Engine < ::Rails::Engine # :nodoc:
3
+ ActiveSupport.on_load(:action_controller) do
4
+ include DevisePasswordChangable::Controllers::Helpers
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+
4
+ protected
5
+
6
+ def devise_password_change(mapping, controllers)
7
+ resource :password_change, :only => [:show, :update], :path => mapping.path_names[:password_change], :controller => controllers[:change_passwords]
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'devise_password_changable'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestDevisePasswordChangable < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise_password_changable
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Szymon Fiedler
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-12 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: devise
28
+ requirement: &id002 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: shoulda
39
+ requirement: &id003 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
50
+ requirement: &id004 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 1.0.0
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: jeweler
61
+ requirement: &id005 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 1.6.0
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *id005
70
+ description: Extension for devise to provide password change without using registerable.
71
+ email: fidelski@gmail.com
72
+ executables: []
73
+
74
+ extensions: []
75
+
76
+ extra_rdoc_files:
77
+ - LICENSE.txt
78
+ - README.rdoc
79
+ files:
80
+ - .document
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - LICENSE.txt
84
+ - README.rdoc
85
+ - Rakefile
86
+ - VERSION
87
+ - app/controllers/devise/change_passwords_controller.rb
88
+ - app/views/devise/change_passwords/show.html.erb
89
+ - config/locales/en.yml
90
+ - devise_password_changable.gemspec
91
+ - lib/devise_password_changable.rb
92
+ - lib/devise_password_changable/controllers/helpers.rb
93
+ - lib/devise_password_changable/models/password_changable.rb
94
+ - lib/devise_password_changable/rails.rb
95
+ - lib/devise_password_changable/routes.rb
96
+ - test/helper.rb
97
+ - test/test_devise_password_changable.rb
98
+ homepage: http://github.com/fidel/devise_password_changable
99
+ licenses:
100
+ - MIT
101
+ post_install_message:
102
+ rdoc_options: []
103
+
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ hash: -383906068214248886
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: "0"
121
+ requirements: []
122
+
123
+ rubyforge_project:
124
+ rubygems_version: 1.7.1
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: Extension for devise to provide password change.
128
+ test_files: []
129
+