janus 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +3 -0
- data/.gitignore +4 -0
- data/.travis.yml +18 -0
- data/LICENSE +20 -0
- data/README.rdoc +4 -5
- data/Rakefile +22 -0
- data/VERSION +1 -0
- data/certs/ysbaddaden.pem +21 -0
- data/janus.gemspec +28 -0
- data/lib/generators/janus/resource_generator.rb +17 -1
- data/lib/generators/templates/janus.rb +9 -5
- data/lib/generators/templates/mailer.rb +3 -0
- data/lib/generators/templates/mailer/confirmation_instructions.html.erb +7 -0
- data/lib/generators/templates/mailer/confirmation_instructions.text.erb +7 -0
- data/lib/generators/templates/mailer/reset_password_instructions.html.erb +9 -0
- data/lib/generators/templates/mailer/reset_password_instructions.text.erb +7 -0
- data/lib/janus.rb +3 -0
- data/lib/janus/config.rb +9 -3
- data/lib/janus/controllers/confirmations_controller.rb +1 -1
- data/lib/janus/controllers/internal_helpers.rb +8 -1
- data/lib/janus/controllers/passwords_controller.rb +1 -1
- data/lib/janus/controllers/registrations_controller.rb +1 -1
- data/lib/janus/controllers/sessions_controller.rb +6 -5
- data/lib/janus/models/confirmable.rb +2 -0
- data/lib/janus/models/database_authenticatable.rb +4 -2
- data/lib/janus/models/rememberable.rb +2 -0
- data/lib/janus/models/remote_authenticatable.rb +2 -0
- data/lib/janus/models/remote_token.rb +6 -5
- data/lib/janus/models/token_authenticatable.rb +79 -0
- data/lib/janus/models/trackable.rb +2 -0
- data/lib/janus/strategies.rb +1 -1
- data/lib/janus/strategies/token_authenticatable.rb +22 -0
- data/lib/janus/version.rb +10 -0
- data/test/fixtures/admins.yml +5 -0
- data/test/fixtures/users.yml +10 -0
- data/test/functional/admins/sessions_controller_test.rb +13 -0
- data/test/functional/home_controller_test.rb +8 -0
- data/test/functional/janus/mailer_test.rb +14 -0
- data/test/functional/janus/manager_test.rb +94 -0
- data/test/functional/users/confirmations_controller_test.rb +68 -0
- data/test/functional/users/passwords_controller_test.rb +131 -0
- data/test/functional/users/registrations_controller_test.rb +112 -0
- data/test/functional/users/sessions_controller_test.rb +100 -0
- data/test/functional/users_controller_test.rb +29 -0
- data/test/generators/install_generator_test.rb +16 -0
- data/test/generators/resource_generator_test.rb +80 -0
- data/test/integration/users/rememberable_test.rb +32 -0
- data/test/integration/users/remote_test.rb +72 -0
- data/test/integration/users/sessions_test.rb +18 -0
- data/test/integration/users/token_authenticatable_test.rb +42 -0
- data/test/integration/users/trackable_test.rb +22 -0
- data/test/rails_app/.gitignore +4 -0
- data/test/rails_app/Rakefile +7 -0
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +11 -0
- data/test/rails_app/app/controllers/application_controller.rb +9 -0
- data/test/rails_app/app/controllers/blogs_controller.rb +6 -0
- data/test/rails_app/app/controllers/home_controller.rb +4 -0
- data/test/rails_app/app/controllers/users/confirmations_controller.rb +3 -0
- data/test/rails_app/app/controllers/users/passwords_controller.rb +3 -0
- data/test/rails_app/app/controllers/users/registrations_controller.rb +17 -0
- data/test/rails_app/app/controllers/users/sessions_controller.rb +11 -0
- data/test/rails_app/app/controllers/users_controller.rb +9 -0
- data/test/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/rails_app/app/mailers/user_mailer.rb +3 -0
- data/test/rails_app/app/models/admin.rb +3 -0
- data/test/rails_app/app/models/remote_token.rb +6 -0
- data/test/rails_app/app/models/user.rb +8 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +30 -0
- data/test/rails_app/app/views/blogs/show.html.erb +2 -0
- data/test/rails_app/app/views/home/index.html.erb +2 -0
- data/test/rails_app/app/views/layouts/application.html.erb +28 -0
- data/test/rails_app/app/views/user_mailer/confirmation_instructions.html.erb +7 -0
- data/test/rails_app/app/views/user_mailer/confirmation_instructions.text.erb +7 -0
- data/test/rails_app/app/views/user_mailer/reset_password_instructions.html.erb +9 -0
- data/test/rails_app/app/views/user_mailer/reset_password_instructions.text.erb +7 -0
- data/test/rails_app/app/views/users/confirmations/new.html.erb +16 -0
- data/test/rails_app/app/views/users/passwords/edit.html.erb +21 -0
- data/test/rails_app/app/views/users/passwords/new.html.erb +16 -0
- data/test/rails_app/app/views/users/registrations/edit.html.erb +31 -0
- data/test/rails_app/app/views/users/registrations/new.html.erb +26 -0
- data/test/rails_app/app/views/users/sessions/new.html.erb +30 -0
- data/test/rails_app/app/views/users/show.html.erb +2 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +43 -0
- data/test/rails_app/config/boot.rb +6 -0
- data/test/rails_app/config/database.yml +22 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +23 -0
- data/test/rails_app/config/environments/production.rb +50 -0
- data/test/rails_app/config/environments/test.rb +34 -0
- data/test/rails_app/config/initializers/janus.rb +25 -0
- data/test/rails_app/config/initializers/secret_token.rb +8 -0
- data/test/rails_app/config/initializers/session_store.rb +8 -0
- data/test/rails_app/config/locales/janus.en.yml +65 -0
- data/test/rails_app/config/routes.rb +13 -0
- data/test/rails_app/db/migrate/20110323153820_create_users.rb +40 -0
- data/test/rails_app/db/migrate/20110331153546_create_remote_tokens.rb +15 -0
- data/test/rails_app/db/migrate/20130412104138_create_admins.rb +10 -0
- data/test/rails_app/db/schema.rb +58 -0
- data/test/rails_app/db/seeds.rb +7 -0
- data/test/rails_app/lib/tasks/.gitkeep +0 -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/script/rails +6 -0
- data/test/test_helper.rb +121 -0
- data/test/unit/confirmable_test.rb +36 -0
- data/test/unit/janus_test.rb +27 -0
- data/test/unit/rememberable_test.rb +47 -0
- data/test/unit/remote_authenticatable_test.rb +37 -0
- data/test/unit/remote_token_test.rb +9 -0
- data/test/unit/reset_password_test.rb +45 -0
- data/test/unit/token_authenticatable_test.rb +41 -0
- data/test/unit/trackable_test.rb +21 -0
- data/test/unit/user_test.rb +68 -0
- metadata +303 -21
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: db69af223011b34004ed7c3b3d3b0b94d1c143ae
|
4
|
+
data.tar.gz: 4648e6814dc5578a272ca63d93d021e7d6753e8c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0ab6bbc22c50eff38c2162aecad2ce3db7a1ba8a21c17cc06a1cb0a96b554bb2322626747176b294a92efd10a0569f7d269244e09a0df6d6a2bbf8ce7dc38d62
|
7
|
+
data.tar.gz: 23e1f598b215370df21ae5b3e20e10ababf958c275364a717e060f228fa2192f66abe2a0cab981fc63f60b5778403f954da1841a78a25003547458775bfe0927
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
script: bundle exec rake test
|
3
|
+
|
4
|
+
rvm:
|
5
|
+
- 1.9.3
|
6
|
+
- 2.0.0
|
7
|
+
- 2.1.0
|
8
|
+
|
9
|
+
gemfile:
|
10
|
+
- Gemfile
|
11
|
+
- gemfiles/Gemfile.rails-4.0-stable
|
12
|
+
- gemfiles/Gemfile.rails-3.2-stable
|
13
|
+
- gemfiles/Gemfile.rails-head
|
14
|
+
|
15
|
+
matrix:
|
16
|
+
allow_failures:
|
17
|
+
- gemfile: gemfiles/Gemfile.rails-head
|
18
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Julien Portalier
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -13,7 +13,7 @@ being sent from the controllers and never from the models.
|
|
13
13
|
|
14
14
|
- full auth system with strategies and hooks;
|
15
15
|
- scoped auth for parallel authentications (like +users+, +admin_users+, etc.);
|
16
|
-
- abstract controllers ready to use;
|
16
|
+
- abstract controllers and mailer ready to use;
|
17
17
|
- generators to have everything generated automatically;
|
18
18
|
- use only what you need at anytime.
|
19
19
|
|
@@ -23,6 +23,8 @@ As for the strategies and hooks:
|
|
23
23
|
to auth users with passwords (plus registration and password reset);
|
24
24
|
- {RemoteAuthenticatable}[http://rdoc.info/github/ysbaddaden/janus/Janus/Models/RemoteAuthenticatable]
|
25
25
|
to keep users signed in across top level domains;
|
26
|
+
- {TokenAuthenticatable}[http://rdoc.info/github/ysbaddaden/janus/Janus/Models/TokenAuthenticatable]
|
27
|
+
to auth users with unique tokens;
|
26
28
|
- {Confirmable}[http://rdoc.info/github/ysbaddaden/janus/Janus/Models/RemoteAuthenticatable]
|
27
29
|
to have users confirm their emails upon registration;
|
28
30
|
- {Rememberable}[http://rdoc.info/github/ysbaddaden/janus/Janus/Models/Rememberable]
|
@@ -77,14 +79,11 @@ Here is the list of all the current strategies:
|
|
77
79
|
- +password+ — reset password (using an email exchanged token)
|
78
80
|
- +track+ — track current and previous user's sign in date and IP
|
79
81
|
- +remote+ — keeps users signed in different top level domains
|
80
|
-
|
82
|
+
- +token+ — get users signed in (with an unique token)
|
81
83
|
|
82
84
|
== TODO
|
83
85
|
|
84
|
-
- Differenciate mailers per resource, by looking for User::Mailer or AdminUser::Mailer classes.
|
85
86
|
- Reconfirmable when email changes.
|
86
|
-
- Simple configuration to use scrypt instead of bcrypt for password encryption.
|
87
|
-
- TokenAuthenticatable strategy.
|
88
87
|
- Rememberable across top level domains.
|
89
88
|
- Omniauthable (or shall we let the user do it himself?)
|
90
89
|
- Providing an OAuth 1.0 service whould be cool.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rdoc/task'
|
4
|
+
|
5
|
+
task :default => :test
|
6
|
+
|
7
|
+
desc 'Test the Janus rack middleware.'
|
8
|
+
Rake::TestTask.new(:test) do |t|
|
9
|
+
t.libs << 'test'
|
10
|
+
#t.pattern = 'test/{unit,functional,integration,generators}/**/*_test.rb'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
Rake::RDocTask.new do |rdoc|
|
16
|
+
rdoc.title = "Janus"
|
17
|
+
rdoc.main = "README.rdoc"
|
18
|
+
rdoc.rdoc_dir = "doc"
|
19
|
+
rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
|
20
|
+
rdoc.options << "--charset=utf-8"
|
21
|
+
end
|
22
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.8.0
|
@@ -0,0 +1,21 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMQ8wDQYDVQQDDAZqdWxp
|
3
|
+
ZW4xGTAXBgoJkiaJk/IsZAEZFglwb3J0YWxpZXIxEzARBgoJkiaJk/IsZAEZFgNj
|
4
|
+
b20wHhcNMTQwMTE0MjIzMTQ4WhcNMTUwMTE0MjIzMTQ4WjBBMQ8wDQYDVQQDDAZq
|
5
|
+
dWxpZW4xGTAXBgoJkiaJk/IsZAEZFglwb3J0YWxpZXIxEzARBgoJkiaJk/IsZAEZ
|
6
|
+
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDpxWuWRJXEz2+p
|
7
|
+
2EW4NOPzkKloRLWoj+WQnqhQKT46GbH3ToDId8AMELTDIKpTQFiG2ty6D7S4IBFv
|
8
|
+
7ceFKNk/EJc17mSYE1DzrtItor2/eeGC1zeNfvLjyDtyHKyKUZ891C1D0so5coUx
|
9
|
+
2YbDW5npFkJkPaA5GneH7DFaCoIFLrD7ekbzaZAjlH+EH2fhd1XLhSsPEIiE+OnD
|
10
|
+
ilWnsPoRJAZwQOiVAtvh7xuc+29uSNndIIm2rU00SxbJnzsAq9ZddwPpMU/UcQpD
|
11
|
+
4gCBCaNGzrLz4+upQdYEOuggM7rR3P934qfhIwb+aRGglqdNunmUrdCuhsGXrxq2
|
12
|
+
FvqwDvFZAgMBAAGjezB5MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
13
|
+
BBQoESDCnNz3LmbpUzOrGeXOpk9sqjAfBgNVHREEGDAWgRRqdWxpZW5AcG9ydGFs
|
14
|
+
aWVyLmNvbTAfBgNVHRIEGDAWgRRqdWxpZW5AcG9ydGFsaWVyLmNvbTANBgkqhkiG
|
15
|
+
9w0BAQUFAAOCAQEAML4w0F/VF0gi5JqMqYSO05TakAauG8jQX0hov5H8M0Xhl79G
|
16
|
+
BdUllH0QEw0cP6J2g46zAk0FGHIGthx0OKKi5YMYTs/KPqOVIAcJslt2sGIC1Ukm
|
17
|
+
wpOWIg1XMe68+JVTktBKcBFAvc0pLtty1TgdSd2wr7KQgfmBU9I8G6AoPYhJOhkG
|
18
|
+
SHTTSX3ms2/XePuSnyOfir/AQC7U0NalnKLNdwY9gkEdNwiTf5Ga/lZVDQ607bow
|
19
|
+
KVqCN//9bevjMk5OiMi9X3Wu/GtVWDwC6OTWFWKd54KgbuWlakO8LC1SMmStnCIF
|
20
|
+
W4qpyMWMZMcB4ZN/0mUVzY5xwrislBtsmQVUSw==
|
21
|
+
-----END CERTIFICATE-----
|
data/janus.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/janus/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Julien Portalier"]
|
6
|
+
gem.email = ["julien@portalier.com"]
|
7
|
+
gem.description = gem.summary = "Authentication engine for Ruby on Rails"
|
8
|
+
gem.homepage = "http://github.com/ysbaddaden/janus"
|
9
|
+
gem.license = "MIT"
|
10
|
+
|
11
|
+
gem.files = `git ls-files | grep -Ev '^(Gemfile|gemfiles|test)'`.split("\n")
|
12
|
+
gem.test_files = `git ls-files -- test/*`.split("\n")
|
13
|
+
gem.name = "janus"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = Janus::VERSION::STRING
|
16
|
+
|
17
|
+
gem.cert_chain = ['certs/ysbaddaden.pem']
|
18
|
+
gem.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $0 =~ /gem\z/
|
19
|
+
|
20
|
+
gem.add_dependency 'addressable'
|
21
|
+
|
22
|
+
gem.add_development_dependency 'rails', '>= 3.0.0'
|
23
|
+
gem.add_development_dependency 'sqlite3'
|
24
|
+
gem.add_development_dependency 'bcrypt-ruby'
|
25
|
+
gem.add_development_dependency 'scrypt'
|
26
|
+
gem.add_development_dependency 'minitest'
|
27
|
+
gem.add_development_dependency 'capybara'
|
28
|
+
end
|
@@ -17,16 +17,17 @@ module Janus
|
|
17
17
|
attributes += %w{reset_password_token:string:uniq reset_password_sent_at:datetime} if strategies.include?('password')
|
18
18
|
attributes += %w{session_token:string:uniq} if strategies.include?('remote')
|
19
19
|
attributes += %w{sign_in_count:integer last_sign_in_at:datetime last_sign_in_ip:string current_sign_in_at:datetime current_sign_in_ip:string} if strategies.include?('track')
|
20
|
+
attributes += %w{authentication_token:string:uniq authentication_token_created_at:datetime} if strategies.include?('token')
|
20
21
|
generate('model', attributes.join(' '))
|
21
22
|
|
22
23
|
modules = [
|
23
|
-
" include Janus::Models::Base",
|
24
24
|
" include Janus::Models::DatabaseAuthenticatable",
|
25
25
|
]
|
26
26
|
modules << " include Janus::Models::Rememberable" if strategies.include?('remember')
|
27
27
|
modules << " include Janus::Models::Confirmable" if strategies.include?('confirmation')
|
28
28
|
modules << " include Janus::Models::Trackable" if strategies.include?('track')
|
29
29
|
modules << " include Janus::Models::RemoteAuthenticatable" if strategies.include?('remote')
|
30
|
+
modules << " include Janus::Models::TokenAuthenticatable" if strategies.include?('token')
|
30
31
|
inject_into_class "app/models/#{singular_name}.rb", class_name, modules.join("\n") + "\n"
|
31
32
|
end
|
32
33
|
|
@@ -51,6 +52,21 @@ module Janus
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
55
|
+
def create_mailer
|
56
|
+
return unless strategies.include?('registration') or strategies.include?('confirmation') or strategies.include?('password')
|
57
|
+
template 'mailer.rb', "app/mailers/#{singular_name}_mailer.rb"
|
58
|
+
|
59
|
+
if strategies.include?('confirmation')
|
60
|
+
template 'mailer/confirmation_instructions.html.erb', "app/views/#{singular_name}_mailer/confirmation_instructions.html.erb"
|
61
|
+
template 'mailer/confirmation_instructions.text.erb', "app/views/#{singular_name}_mailer/confirmation_instructions.text.erb"
|
62
|
+
end
|
63
|
+
|
64
|
+
if strategies.include?('password')
|
65
|
+
template 'mailer/reset_password_instructions.html.erb', "app/views/#{singular_name}_mailer/reset_password_instructions.html.erb"
|
66
|
+
template 'mailer/reset_password_instructions.text.erb', "app/views/#{singular_name}_mailer/reset_password_instructions.text.erb"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
54
70
|
def add_janus_route
|
55
71
|
route "janus :#{plural_name}, " + controllers.map { |ctrl| ":#{ctrl} => true" }.join(', ')
|
56
72
|
end
|
@@ -2,14 +2,14 @@ Janus.config do |config|
|
|
2
2
|
config.contact_email = "contact@some-example-domain.com"
|
3
3
|
|
4
4
|
# DatabaseAuthenticatable
|
5
|
-
config.authentication_keys = [
|
5
|
+
config.authentication_keys = [:email]
|
6
6
|
|
7
|
-
#
|
7
|
+
# bcrypt:
|
8
8
|
config.encryptor = :bcrypt
|
9
|
-
config.stretches = 10
|
9
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
10
10
|
config.pepper = <%= SecureRandom.hex(64).inspect %>
|
11
11
|
|
12
|
-
#
|
12
|
+
# scrypt:
|
13
13
|
# config.encryptor = :scrypt
|
14
14
|
# config.scrypt_options = { :max_time => 0.25 }
|
15
15
|
|
@@ -21,5 +21,9 @@ Janus.config do |config|
|
|
21
21
|
# config.extend_remember_period = false
|
22
22
|
|
23
23
|
# RemoteAuthenticatable
|
24
|
-
# config.remote_authentication_key = :
|
24
|
+
# config.remote_authentication_key = :remote_token
|
25
|
+
|
26
|
+
# TokenAuthenticatable
|
27
|
+
# config.token_authentication_key = :auth_token
|
28
|
+
# self.reusable_authentication_token = true
|
25
29
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p><%%= t('janus.mailer.hello') %><p>
|
2
|
+
|
3
|
+
<p><%%= t('janus.mailer.confirmation_instructions.confirm') %></p>
|
4
|
+
|
5
|
+
<p><%%= link_to t('janus.mailer.confirmation_instructions.confirm_my_account'),
|
6
|
+
<%= singular_name %>_confirmation_url(@<%= class_name %>.confirmation_key => @<%= singular_name %>.confirmation_token) %></p>
|
7
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<%%= t('janus.mailer.hello') %>
|
2
|
+
|
3
|
+
<%%= t('janus.mailer.confirmation_instructions.confirm') %>
|
4
|
+
|
5
|
+
<%%= link_to t('janus.mailer.confirmation_instructions.confirm_my_account'),
|
6
|
+
<%= singular_name %>_confirmation_url(@<%= class_name %>.confirmation_key => @<%= singular_name %>.confirmation_token) %>
|
7
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<p><%%= t('janus.mailer.hello') %><p>
|
2
|
+
|
3
|
+
<p><%%= t('janus.mailer.reset_password_instructions.infos') %></p>
|
4
|
+
|
5
|
+
<p><%%= link_to t('janus.mailer.reset_password_instructions.change_password_link'),
|
6
|
+
edit_<%= singular_name %>_password_url(:token => @<%= singular_name %>.reset_password_token) %></p>
|
7
|
+
|
8
|
+
<p><%%= t('janus.mailer.reset_password_instructions.please_ignore_your_password_wont_change') %></p>
|
9
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<%%= t('janus.mailer.hello') %>
|
2
|
+
|
3
|
+
<%%= t('janus.mailer.reset_password_instructions.infos') %>
|
4
|
+
<%%= edit_<%= singular_name %>_password_url(:token => @<%= singular_name %>.reset_password_token) %>
|
5
|
+
|
6
|
+
<%%= t('janus.mailer.reset_password_instructions.please_ignore_your_password_wont_change') %>
|
7
|
+
|
data/lib/janus.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_support/core_ext/class'
|
2
|
+
require 'janus/version'
|
2
3
|
require 'janus/config'
|
3
4
|
require 'janus/hooks'
|
4
5
|
require 'janus/strategies'
|
@@ -25,12 +26,14 @@ module Janus
|
|
25
26
|
autoload :RemoteAuthenticatable, 'janus/models/remote_authenticatable'
|
26
27
|
autoload :RemoteToken, 'janus/models/remote_token'
|
27
28
|
autoload :Trackable, 'janus/models/trackable'
|
29
|
+
autoload :TokenAuthenticatable, 'janus/models/token_authenticatable'
|
28
30
|
end
|
29
31
|
|
30
32
|
module Strategies
|
31
33
|
autoload :Base, 'janus/strategies/base'
|
32
34
|
autoload :Rememberable, 'janus/strategies/rememberable'
|
33
35
|
autoload :RemoteAuthenticatable, 'janus/strategies/remote_authenticatable'
|
36
|
+
autoload :TokenAuthenticatable, 'janus/strategies/token_authenticatable'
|
34
37
|
end
|
35
38
|
|
36
39
|
def self.scope_for(user_or_scope)
|
data/lib/janus/config.rb
CHANGED
@@ -9,7 +9,7 @@ module Janus
|
|
9
9
|
self.authentication_keys = [ :email ]
|
10
10
|
|
11
11
|
self.encryptor = :bcrypt
|
12
|
-
#
|
12
|
+
#self.encryptor = :scrypt
|
13
13
|
|
14
14
|
# bcrypt config
|
15
15
|
self.stretches = 10
|
@@ -21,16 +21,22 @@ module Janus
|
|
21
21
|
# Confirmable
|
22
22
|
mattr_accessor :confirmation_key #,reconfirmable
|
23
23
|
self.confirmation_key = :confirm_token
|
24
|
-
#
|
24
|
+
#self.reconfirmable = true
|
25
25
|
|
26
26
|
# Rememberable
|
27
27
|
mattr_accessor :remember_for, :extend_remember_period #, :remember_across_browsers
|
28
28
|
self.remember_for = 1.year
|
29
29
|
self.extend_remember_period = false
|
30
|
-
#
|
30
|
+
#self.remember_across_browsers = false
|
31
31
|
|
32
32
|
# RemoteAuthenticatable
|
33
33
|
mattr_accessor :remote_authentication_key
|
34
34
|
self.remote_authentication_key = :remote_token
|
35
|
+
|
36
|
+
# TokenAuthenticatable
|
37
|
+
mattr_accessor :token_authentication_key, :token_authentication_valid_for, :reusable_authentication_token
|
38
|
+
self.token_authentication_key = :auth_token
|
39
|
+
self.token_authentication_valid_for = nil
|
40
|
+
self.reusable_authentication_token = true
|
35
41
|
end
|
36
42
|
end
|
@@ -37,7 +37,7 @@ class Janus::ConfirmationsController < ApplicationController
|
|
37
37
|
self.resource = resource_class.find_for_database_authentication(params[resource_name])
|
38
38
|
|
39
39
|
if resource
|
40
|
-
|
40
|
+
mailer_class.confirmation_instructions(resource).deliver
|
41
41
|
|
42
42
|
respond_to do |format|
|
43
43
|
format.html { redirect_to root_url, :notice => t('flash.janus.confirmations.create.email_sent') }
|
@@ -32,7 +32,8 @@ module Janus
|
|
32
32
|
instance_variable_set(:"@#{janus_scope}", value)
|
33
33
|
end
|
34
34
|
|
35
|
-
# Returns the `User` class (or `Admin` or whatever) as detected by
|
35
|
+
# Returns the `User` class (or `Admin` or whatever) as detected by
|
36
|
+
# janus_scope.
|
36
37
|
def resource_class
|
37
38
|
@resource_class ||= janus_scope.camelize.constantize
|
38
39
|
end
|
@@ -41,5 +42,11 @@ module Janus
|
|
41
42
|
def resource_name
|
42
43
|
janus_scope
|
43
44
|
end
|
45
|
+
|
46
|
+
# Returns the `UserMailer` class (or `AdminMailer` or whatever) as detected
|
47
|
+
# by janus_scope.
|
48
|
+
def mailer_class
|
49
|
+
@mailer_class ||= (janus_scope.camelize + 'Mailer').constantize
|
50
|
+
end
|
44
51
|
end
|
45
52
|
end
|
@@ -15,7 +15,7 @@ class Janus::PasswordsController < ApplicationController
|
|
15
15
|
|
16
16
|
if resource
|
17
17
|
resource.generate_reset_password_token!
|
18
|
-
|
18
|
+
mailer_class.reset_password_instructions(resource).deliver
|
19
19
|
|
20
20
|
respond_to do |format|
|
21
21
|
format.html { redirect_to root_url, :notice => t('flash.janus.passwords.create.email_sent') }
|
@@ -21,7 +21,7 @@ class Janus::RegistrationsController < ApplicationController
|
|
21
21
|
|
22
22
|
if resource.save
|
23
23
|
janus.login(resource, :scope => janus_scope, :rememberable => true)
|
24
|
-
|
24
|
+
mailer_class.confirmation_instructions(resource).deliver if resource.respond_to?(:confirm!)
|
25
25
|
else
|
26
26
|
resource.clean_up_passwords
|
27
27
|
end
|
@@ -93,11 +93,12 @@ class Janus::SessionsController < ApplicationController
|
|
93
93
|
#
|
94
94
|
def never_return_to(scope)
|
95
95
|
scope = Janus.scope_for(scope)
|
96
|
-
[
|
97
|
-
|
98
|
-
new_password_path(scope),
|
99
|
-
|
100
|
-
|
96
|
+
list = [new_session_path(scope)]
|
97
|
+
begin
|
98
|
+
list + [ destroy_session_path(scope), new_password_path(scope), edit_password_path(scope) ]
|
99
|
+
rescue NoMethodError
|
100
|
+
list
|
101
|
+
end
|
101
102
|
end
|
102
103
|
|
103
104
|
# Either redirects the user to after_sign_in_url or to <tt>params[:return_to]</tt>.
|
@@ -1,11 +1,11 @@
|
|
1
1
|
begin
|
2
2
|
require 'bcrypt'
|
3
|
-
rescue
|
3
|
+
rescue LoadError
|
4
4
|
end
|
5
5
|
|
6
6
|
begin
|
7
7
|
require 'scrypt'
|
8
|
-
rescue
|
8
|
+
rescue LoadError
|
9
9
|
end
|
10
10
|
|
11
11
|
module Janus
|
@@ -31,6 +31,8 @@ module Janus
|
|
31
31
|
extend ActiveSupport::Concern
|
32
32
|
|
33
33
|
included do
|
34
|
+
include Janus::Models::Base unless include?(Janus::Models::Base)
|
35
|
+
|
34
36
|
begin
|
35
37
|
attr_protected :encrypted_password, :reset_password_token, :reset_password_sent_at
|
36
38
|
rescue
|