Sha256: 0c35bccf1d753cc598de5125aef8694184f5543527012c4840ca36c614a6de1f

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

module Cms
  module Authentication
    # For testing external authentication.
    class TestPasswordStrategy < Devise::Strategies::Authenticatable
      EXPECTED_LOGIN = EXPECTED_PASSWORD = 'test'
      def authenticate!
        if(authentication_hash[:login] == password && password == EXPECTED_PASSWORD)
          user = Cms::ExternalUser.authenticate(authentication_hash[:login], 'Test Password', {first_name: "Test", last_name: "User"})
          user.authorize(Cms::UsersService::GROUP_CMS_ADMIN, Cms::UsersService::GROUP_CONTENT_EDITOR)
          success!(user)
        else
          pass
        end
      end
    end
  end
end

Warden::Strategies.add(:test_password, Cms::Authentication::TestPasswordStrategy)

# NOTE:  To enable a custom password strategy for BrowserCMS you must also add it to to the devise configuration.
# 
# For example enable the test_password strategy above by adding the following to config/initializers/devise.rb

# # Add test_password strategy BEFORE other CMS authentication strategies
# config.warden do |manager|
#   manager.default_strategies(:scope => :cms_user).unshift :test_password
# end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
browsercms-artirix-4.0.4 lib/cms/authentication/test_password_strategy.rb
browsercms-artirix-4.0.3.3 lib/cms/authentication/test_password_strategy.rb
browsercms-artirix-4.0.3.2 lib/cms/authentication/test_password_strategy.rb
browsercms-artirix-4.0.3.1 lib/cms/authentication/test_password_strategy.rb
browsercms-artirix-4.0.3 lib/cms/authentication/test_password_strategy.rb
browsercms-artirix-4.0.2 lib/cms/authentication/test_password_strategy.rb
browsercms-artirix-4.0.1.1 lib/cms/authentication/test_password_strategy.rb