devise_openid_authenticatable 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +18 -9
- data/CHANGELOG.rdoc +5 -0
- data/Gemfile +6 -1
- data/Gemfile.devise13 +4 -4
- data/Gemfile.devise13.lock +148 -0
- data/Gemfile.devise14 +4 -4
- data/Gemfile.devise14.lock +150 -0
- data/Gemfile.devise15 +4 -4
- data/Gemfile.devise15.lock +161 -0
- data/Gemfile.devise21 +4 -4
- data/Gemfile.devise21.lock +160 -0
- data/Gemfile.devise30 +5 -4
- data/Gemfile.devise30.lock +151 -0
- data/Gemfile.devise33 +12 -0
- data/Gemfile.devise33.lock +150 -0
- data/Gemfile.devise35 +13 -0
- data/Gemfile.devise35.lock +153 -0
- data/Gemfile.devise42 +14 -0
- data/Gemfile.devise42.lock +189 -0
- data/devise_openid_authenticatable.gemspec +4 -1
- data/lib/devise_openid_authenticatable/controller.rb +4 -4
- data/lib/devise_openid_authenticatable/strategy.rb +20 -8
- data/lib/devise_openid_authenticatable/version.rb +1 -1
- data/rails/Rakefile +6 -0
- data/rails/app/active_record/admin.rb +6 -0
- data/rails/app/active_record/shim.rb +2 -0
- data/rails/app/active_record/user.rb +7 -0
- data/rails/app/active_record/user_on_engine.rb +7 -0
- data/rails/app/active_record/user_on_main_app.rb +7 -0
- data/rails/app/active_record/user_without_email.rb +8 -0
- data/rails/app/controllers/admins/sessions_controller.rb +6 -0
- data/rails/app/controllers/admins_controller.rb +6 -0
- data/rails/app/controllers/application_controller.rb +11 -0
- data/rails/app/controllers/application_with_fake_engine.rb +30 -0
- data/rails/app/controllers/custom/registrations_controller.rb +31 -0
- data/rails/app/controllers/home_controller.rb +29 -0
- data/rails/app/controllers/publisher/registrations_controller.rb +2 -0
- data/rails/app/controllers/publisher/sessions_controller.rb +2 -0
- data/rails/app/controllers/users/omniauth_callbacks_controller.rb +14 -0
- data/rails/app/controllers/users_controller.rb +31 -0
- data/rails/app/helpers/application_helper.rb +3 -0
- data/rails/app/mailers/users/from_proc_mailer.rb +3 -0
- data/rails/app/mailers/users/mailer.rb +3 -0
- data/rails/app/mailers/users/reply_to_mailer.rb +4 -0
- data/rails/app/mongoid/admin.rb +29 -0
- data/rails/app/mongoid/shim.rb +23 -0
- data/rails/app/mongoid/user.rb +39 -0
- data/rails/app/mongoid/user_on_engine.rb +39 -0
- data/rails/app/mongoid/user_on_main_app.rb +39 -0
- data/rails/app/mongoid/user_without_email.rb +33 -0
- data/rails/app/views/admins/index.html.erb +1 -0
- data/rails/app/views/admins/sessions/new.html.erb +2 -0
- data/rails/app/views/home/admin_dashboard.html.erb +1 -0
- data/rails/app/views/home/index.html.erb +1 -0
- data/rails/app/views/home/join.html.erb +1 -0
- data/rails/app/views/home/private.html.erb +1 -0
- data/rails/app/views/home/user_dashboard.html.erb +1 -0
- data/rails/app/views/layouts/application.html.erb +24 -0
- data/rails/app/views/users/edit_form.html.erb +1 -0
- data/rails/app/views/users/index.html.erb +1 -0
- data/rails/app/views/users/mailer/confirmation_instructions.erb +1 -0
- data/rails/app/views/users/sessions/new.html.erb +1 -0
- data/rails/bin/bundle +3 -0
- data/rails/bin/rails +4 -0
- data/rails/bin/rake +4 -0
- data/rails/config.ru +4 -0
- data/rails/config/application.rb +44 -0
- data/rails/config/boot.rb +14 -0
- data/rails/config/database.yml +18 -0
- data/rails/config/environment.rb +5 -0
- data/rails/config/environments/development.rb +30 -0
- data/rails/config/environments/production.rb +86 -0
- data/rails/config/environments/test.rb +45 -0
- data/rails/config/initializers/backtrace_silencers.rb +7 -0
- data/rails/config/initializers/devise.rb +180 -0
- data/rails/config/initializers/inflections.rb +2 -0
- data/rails/config/initializers/secret_token.rb +3 -0
- data/rails/config/initializers/session_store.rb +1 -0
- data/rails/config/routes.rb +126 -0
- data/rails/db/migrate/20100401102949_create_tables.rb +75 -0
- data/rails/db/schema.rb +55 -0
- data/rails/lib/shared_admin.rb +17 -0
- data/rails/lib/shared_user.rb +30 -0
- data/rails/lib/shared_user_without_email.rb +26 -0
- data/rails/lib/shared_user_without_omniauth.rb +13 -0
- data/rails/public/404.html +26 -0
- data/rails/public/422.html +26 -0
- data/rails/public/500.html +26 -0
- data/rails/public/favicon.ico +0 -0
- data/spec/scenario/config/environments/test.rb +3 -2
- data/spec/scenario/config/initializers/devise.rb +3 -0
- data/spec/scenario/config/initializers/secret_token.rb +4 -1
- data/spec/spec_helper.rb +10 -4
- data/spec/strategy_spec.rb +38 -25
- metadata +96 -4
- data/rails/init.rb +0 -1
data/rails/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
protect_from_forgery
|
6
|
+
before_action :current_user, unless: :devise_controller?
|
7
|
+
before_action :authenticate_user!, if: :devise_controller?
|
8
|
+
respond_to(*Mime::SET.map(&:to_sym))
|
9
|
+
|
10
|
+
devise_group :commenter, contains: [:user, :admin]
|
11
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class ApplicationWithFakeEngine < ApplicationController
|
2
|
+
private
|
3
|
+
|
4
|
+
helper_method :fake_engine
|
5
|
+
def fake_engine
|
6
|
+
@fake_engine ||= FakeEngine.new
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class FakeEngine
|
11
|
+
def user_on_engine_confirmation_path
|
12
|
+
'/user_on_engine/confirmation'
|
13
|
+
end
|
14
|
+
|
15
|
+
def new_user_on_engine_session_path
|
16
|
+
'/user_on_engine/confirmation/new'
|
17
|
+
end
|
18
|
+
|
19
|
+
def new_user_on_engine_registration_path
|
20
|
+
'/user_on_engine/registration/new'
|
21
|
+
end
|
22
|
+
|
23
|
+
def new_user_on_engine_password_path
|
24
|
+
'/user_on_engine/password/new'
|
25
|
+
end
|
26
|
+
|
27
|
+
def new_user_on_engine_unlock_path
|
28
|
+
'/user_on_engine/unlock/new'
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Custom::RegistrationsController < Devise::RegistrationsController
|
2
|
+
def new
|
3
|
+
super do |resource|
|
4
|
+
@new_block_called = true
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
super do |resource|
|
10
|
+
@create_block_called = true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def update
|
15
|
+
super do |resource|
|
16
|
+
@update_block_called = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_block_called?
|
21
|
+
@create_block_called == true
|
22
|
+
end
|
23
|
+
|
24
|
+
def update_block_called?
|
25
|
+
@update_block_called == true
|
26
|
+
end
|
27
|
+
|
28
|
+
def new_block_called?
|
29
|
+
@new_block_called == true
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class HomeController < ApplicationController
|
2
|
+
def index
|
3
|
+
end
|
4
|
+
|
5
|
+
def private
|
6
|
+
end
|
7
|
+
|
8
|
+
def user_dashboard
|
9
|
+
end
|
10
|
+
|
11
|
+
def admin_dashboard
|
12
|
+
end
|
13
|
+
|
14
|
+
def join
|
15
|
+
end
|
16
|
+
|
17
|
+
def set
|
18
|
+
session["devise.foo_bar"] = "something"
|
19
|
+
head :ok
|
20
|
+
end
|
21
|
+
|
22
|
+
def unauthenticated
|
23
|
+
if Devise.rails5?
|
24
|
+
render body: "unauthenticated", status: :unauthorized
|
25
|
+
else
|
26
|
+
render text: "unauthenticated", status: :unauthorized
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
|
+
def facebook
|
3
|
+
data = request.respond_to?(:get_header) ? request.get_header("omniauth.auth") : request.env["omniauth.auth"]
|
4
|
+
session["devise.facebook_data"] = data["extra"]["user_hash"]
|
5
|
+
render json: data
|
6
|
+
end
|
7
|
+
|
8
|
+
def sign_in_facebook
|
9
|
+
user = User.to_adapter.find_first(email: 'user@test.com')
|
10
|
+
user.remember_me = true
|
11
|
+
sign_in user
|
12
|
+
render (Devise.rails5? ? :body : :text) => ""
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
prepend_before_action :current_user, only: :exhibit
|
3
|
+
before_action :authenticate_user!, except: [:accept, :exhibit]
|
4
|
+
respond_to :html, :xml
|
5
|
+
|
6
|
+
def index
|
7
|
+
user_session[:cart] = "Cart"
|
8
|
+
respond_with(current_user)
|
9
|
+
end
|
10
|
+
|
11
|
+
def edit_form
|
12
|
+
user_session['last_request_at'] = params.fetch(:last_request_at, 31.minutes.ago.utc)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update_form
|
16
|
+
render (Devise.rails5? ? :body : :text) => 'Update'
|
17
|
+
end
|
18
|
+
|
19
|
+
def accept
|
20
|
+
@current_user = current_user
|
21
|
+
end
|
22
|
+
|
23
|
+
def exhibit
|
24
|
+
render (Devise.rails5? ? :body : :text) => current_user ? "User is authenticated" : "User is not authenticated"
|
25
|
+
end
|
26
|
+
|
27
|
+
def expire
|
28
|
+
user_session['last_request_at'] = 31.minutes.ago.utc
|
29
|
+
render (Devise.rails5? ? :body : :text) => 'User will be expired on next request'
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'shared_admin'
|
2
|
+
|
3
|
+
class Admin
|
4
|
+
include Mongoid::Document
|
5
|
+
include Shim
|
6
|
+
include SharedAdmin
|
7
|
+
|
8
|
+
## Database authenticatable
|
9
|
+
field :email, type: String
|
10
|
+
field :encrypted_password, type: String
|
11
|
+
|
12
|
+
## Recoverable
|
13
|
+
field :reset_password_token, type: String
|
14
|
+
field :reset_password_sent_at, type: Time
|
15
|
+
|
16
|
+
## Rememberable
|
17
|
+
field :remember_created_at, type: Time
|
18
|
+
|
19
|
+
## Confirmable
|
20
|
+
field :confirmation_token, type: String
|
21
|
+
field :confirmed_at, type: Time
|
22
|
+
field :confirmation_sent_at, type: Time
|
23
|
+
field :unconfirmed_email, type: String # Only if using reconfirmable
|
24
|
+
|
25
|
+
## Lockable
|
26
|
+
field :locked_at, type: Time
|
27
|
+
|
28
|
+
field :active, type: Boolean, default: false
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Shim
|
2
|
+
extend ::ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
include ::Mongoid::Timestamps
|
6
|
+
field :created_at, type: DateTime
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def order(attribute)
|
11
|
+
asc(attribute)
|
12
|
+
end
|
13
|
+
|
14
|
+
def find_by_email(email)
|
15
|
+
find_by(email: email)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# overwrite equality (because some devise tests use this for asserting model equality)
|
20
|
+
def ==(other)
|
21
|
+
other.is_a?(self.class) && _id == other._id
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'shared_user'
|
2
|
+
|
3
|
+
class User
|
4
|
+
include Mongoid::Document
|
5
|
+
include Shim
|
6
|
+
include SharedUser
|
7
|
+
|
8
|
+
field :username, type: String
|
9
|
+
field :facebook_token, type: String
|
10
|
+
|
11
|
+
## Database authenticatable
|
12
|
+
field :email, type: String, default: ""
|
13
|
+
field :encrypted_password, type: String, default: ""
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
field :reset_password_token, type: String
|
17
|
+
field :reset_password_sent_at, type: Time
|
18
|
+
|
19
|
+
## Rememberable
|
20
|
+
field :remember_created_at, type: Time
|
21
|
+
|
22
|
+
## Trackable
|
23
|
+
field :sign_in_count, type: Integer, default: 0
|
24
|
+
field :current_sign_in_at, type: Time
|
25
|
+
field :last_sign_in_at, type: Time
|
26
|
+
field :current_sign_in_ip, type: String
|
27
|
+
field :last_sign_in_ip, type: String
|
28
|
+
|
29
|
+
## Confirmable
|
30
|
+
field :confirmation_token, type: String
|
31
|
+
field :confirmed_at, type: Time
|
32
|
+
field :confirmation_sent_at, type: Time
|
33
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
34
|
+
|
35
|
+
## Lockable
|
36
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
37
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
38
|
+
field :locked_at, type: Time
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'shared_user_without_omniauth'
|
2
|
+
|
3
|
+
class UserOnEngine
|
4
|
+
include Mongoid::Document
|
5
|
+
include Shim
|
6
|
+
include SharedUserWithoutOmniauth
|
7
|
+
|
8
|
+
field :username, type: String
|
9
|
+
field :facebook_token, type: String
|
10
|
+
|
11
|
+
## Database authenticatable
|
12
|
+
field :email, type: String, default: ""
|
13
|
+
field :encrypted_password, type: String, default: ""
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
field :reset_password_token, type: String
|
17
|
+
field :reset_password_sent_at, type: Time
|
18
|
+
|
19
|
+
## Rememberable
|
20
|
+
field :remember_created_at, type: Time
|
21
|
+
|
22
|
+
## Trackable
|
23
|
+
field :sign_in_count, type: Integer, default: 0
|
24
|
+
field :current_sign_in_at, type: Time
|
25
|
+
field :last_sign_in_at, type: Time
|
26
|
+
field :current_sign_in_ip, type: String
|
27
|
+
field :last_sign_in_ip, type: String
|
28
|
+
|
29
|
+
## Confirmable
|
30
|
+
field :confirmation_token, type: String
|
31
|
+
field :confirmed_at, type: Time
|
32
|
+
field :confirmation_sent_at, type: Time
|
33
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
34
|
+
|
35
|
+
## Lockable
|
36
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
37
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
38
|
+
field :locked_at, type: Time
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'shared_user_without_omniauth'
|
2
|
+
|
3
|
+
class UserOnMainApp
|
4
|
+
include Mongoid::Document
|
5
|
+
include Shim
|
6
|
+
include SharedUserWithoutOmniauth
|
7
|
+
|
8
|
+
field :username, type: String
|
9
|
+
field :facebook_token, type: String
|
10
|
+
|
11
|
+
## Database authenticatable
|
12
|
+
field :email, type: String, default: ""
|
13
|
+
field :encrypted_password, type: String, default: ""
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
field :reset_password_token, type: String
|
17
|
+
field :reset_password_sent_at, type: Time
|
18
|
+
|
19
|
+
## Rememberable
|
20
|
+
field :remember_created_at, type: Time
|
21
|
+
|
22
|
+
## Trackable
|
23
|
+
field :sign_in_count, type: Integer, default: 0
|
24
|
+
field :current_sign_in_at, type: Time
|
25
|
+
field :last_sign_in_at, type: Time
|
26
|
+
field :current_sign_in_ip, type: String
|
27
|
+
field :last_sign_in_ip, type: String
|
28
|
+
|
29
|
+
## Confirmable
|
30
|
+
field :confirmation_token, type: String
|
31
|
+
field :confirmed_at, type: Time
|
32
|
+
field :confirmation_sent_at, type: Time
|
33
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
34
|
+
|
35
|
+
## Lockable
|
36
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
37
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
38
|
+
field :locked_at, type: Time
|
39
|
+
end
|