beyond_canvas 0.15.3.pre → 0.16.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c99bc0b145e7d7bf5e4bfa4c34bc419905684a3042c6c271c9c18841a154f95
4
- data.tar.gz: 881dcf747b8a6c24abc2412286b127dfd92f538bbd59fe190877cc7ffb384b31
3
+ metadata.gz: 0100f13f9ddfdf8b74b3edae25471d479d5a3351ecc5191f9cfa069a3d4c6b3f
4
+ data.tar.gz: e73fdde1ebee7d45422f052c66791a0b86938b52df74930042b4fc67aa6008af
5
5
  SHA512:
6
- metadata.gz: 26a751147067f809f2a9b7cb52835a0125cf1426eb9873b5e67534d515f1c05080640dcbeb6ec4cf099e026dd3d8d207c2a7714aab26d7d33d6c2b9954b6b233
7
- data.tar.gz: c070ae8eee82ea3679ed8e1703fc6151b3404dfe8f8cd4e35b89a7bb004d58e17706e5aff7553533a82c10f5dad5d180737c5022b544a78d169f7e75397f2a1f
6
+ metadata.gz: b622d131dfe607dbfee52c65b3b0294d609afa3deeb339c9597a46c9dc847cedf578ff8ac2ce3d3dca106fc240b97b3da44be3de75c62a326f5c54739618ec5f
7
+ data.tar.gz: 86eb83c6da624ca5706737f48270bfa85819a57be85795188426a1a263c1f10480c16b83579c349d06e4c33da9bfa61543e9076286ae570ab033b7202104c0ec
data/README.md CHANGED
@@ -37,12 +37,6 @@
37
37
  //= require beyond_canvas
38
38
  ```
39
39
 
40
- 1. Mount the engine in your routes file:
41
-
42
- ```ruby
43
- mount BeyondCanvas::Engine => "/<your-mounting-path>"
44
- ```
45
-
46
40
  1. Run the generator:
47
41
 
48
42
  ```bash
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency 'beyond_canvas/application_controller'
4
+
5
+ module BeyondCanvas
6
+ class AuthenticationsController < ApplicationController # :nodoc:
7
+ layout 'beyond_canvas/public'
8
+
9
+ include ::BeyondCanvas::Authentication
10
+ include ::BeyondCanvas::ResourceManagement
11
+
12
+ before_action :validate_app_installation_request!, only: :new
13
+
14
+ def new
15
+ self.resource = resource_class.new
16
+ end
17
+
18
+ def create
19
+ # Search for the api url. If there is no record it creates a new record.
20
+ resource_params = new_resource_params
21
+ self.resource = resource_class.find_or_create_by(beyond_api_url: resource_params[:api_url])
22
+ # Assign the attributes to the record
23
+ raise ActiveRecord::RecordNotSaved unless resource.update(resource_params)
24
+ # Get and save access_token and refresh_token using the authentication code
25
+ raise BeyondApi::Error if resource.authenticate.is_a?(BeyondApi::Error)
26
+
27
+ redirect_to after_create_path
28
+ rescue ActiveRecord::RecordNotSaved, BeyondApi::Error, StandardError => e
29
+ logger.error "[BeyondCanvas] #{e.message}".red
30
+ send "handle_#{e.class.name.split('::').first.underscore}_exception", e
31
+ end
32
+
33
+ def update
34
+ create
35
+ end
36
+
37
+ private
38
+
39
+ def new_resource_params
40
+ send "new_#{resource_name}_params"
41
+ end
42
+
43
+ def after_create_path
44
+ new_resource_params[:return_url]
45
+ end
46
+
47
+ def handle_active_record_exception(_exception)
48
+ flash[:error] = t('beyond_canvas.authentications.failure')
49
+ render :new
50
+ end
51
+
52
+ def handle_beyond_api_exception(_exception)
53
+ flash[:error] = t('beyond_canvas.authentications.failure')
54
+ render :new
55
+ end
56
+
57
+ def handle_standard_error_exception(_exception)
58
+ flash[:error] = t('beyond_canvas.authentications.failure')
59
+ render :new
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ module Authentication # :nodoc:
5
+ extend ActiveSupport::Concern
6
+ AUTH_RESOURCE = BeyondCanvas.auth_model
7
+
8
+ class_eval <<-METHODS, __FILE__, __LINE__ + 1
9
+ def current_#{AUTH_RESOURCE}
10
+ instance_variable_get("@#{AUTH_RESOURCE}")
11
+ end
12
+
13
+ def new_#{AUTH_RESOURCE}_params
14
+ beyond_canvas_parameter_sanitizer.sanitize
15
+ end
16
+ METHODS
17
+
18
+ private
19
+
20
+ def beyond_canvas_parameter_sanitizer
21
+ @beyond_canvas_parameter_sanitizer ||= BeyondCanvas::ParameterSanitizer.new(AUTH_RESOURCE, params)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ module ResourceManagement # :nodoc:
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ # Share some methods defined in the controller to make them available for the view
9
+ if respond_to?(:helper_method)
10
+ helpers = %w[resource resource_name resource_class]
11
+ helper_method(*helpers)
12
+ end
13
+ end
14
+
15
+ protected
16
+
17
+ def resource_name
18
+ BeyondCanvas.auth_model
19
+ end
20
+
21
+ def resource
22
+ instance_variable_get(:"@#{resource_name}")
23
+ end
24
+
25
+ def resource=(new_resource)
26
+ instance_variable_set(:"@#{resource_name}", new_resource)
27
+ end
28
+
29
+ def resource_class
30
+ resource_name.classify.constantize
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ <div class='card card--padding'>
2
+
3
+ <%= form_for(resource, as: resource_name) do |f| %>
4
+
5
+ <h2 class='card__headline'>Install <%= BeyondCanvas.configuration.site_title %> in your shop</h2>
6
+
7
+ <%= f.hidden_field :code, value: params[:code] || resource.code %>
8
+ <%= f.hidden_field :signature, value: params[:signature] || resource.signature %>
9
+ <%= f.hidden_field :return_url, value: params[:return_url] || resource.return_url %>
10
+ <%= f.hidden_field :api_url, value: params[:api_url] || resource.api_url %>
11
+ <%= f.hidden_field :access_token_url, value: params[:access_token_url] || resource.access_token_url %>
12
+
13
+ <div class='form__actions--spaced'>
14
+ <%= f.button 'Save', type: :submit, class: 'button__solid--primary' %>
15
+ </div>
16
+
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,4 @@
1
+ en:
2
+ beyond_canvas:
3
+ authentications:
4
+ failure: Shop could not be saved
@@ -2,4 +2,10 @@
2
2
 
3
3
  BeyondCanvas::Engine.routes.draw do
4
4
  put '/locale', to: 'system#update_locale', as: :update_locale
5
+
6
+ def create_default_routes(resource_name)
7
+ resources resource_name, controller: 'authentications', except: :destroy
8
+ end
9
+
10
+ create_default_routes(BeyondCanvas.auth_model.pluralize.to_sym) unless BeyondCanvas.use_rails_app_controller
5
11
  end
@@ -12,10 +12,30 @@ require 'http/accept'
12
12
  require 'premailer/rails'
13
13
 
14
14
  require 'beyond_api'
15
+ require 'attr_encrypted'
16
+ require 'blind_index'
15
17
 
16
18
  module BeyondCanvas # :nodoc:
17
- autoload :AssetRegistration, 'beyond_canvas/asset_registration'
18
- autoload :Configuration, 'beyond_canvas/configuration'
19
+ autoload :AssetRegistration, 'beyond_canvas/asset_registration'
20
+ autoload :Configuration, 'beyond_canvas/configuration'
21
+
22
+ module Models # :nodoc:
23
+ autoload :Authentication, 'beyond_canvas/models/authentication'
24
+ autoload :Shop, 'beyond_canvas/models/shop'
25
+ autoload :Utils, 'beyond_canvas/models/utils'
26
+ end
27
+
28
+ autoload :ParameterSanitizer, 'beyond_canvas/parameter_sanitizer'
29
+
30
+ mattr_accessor :use_rails_app_controller
31
+ @@use_rails_app_controller = false # rubocop:disable Style/ClassVars
32
+
33
+ mattr_accessor :auth_model
34
+ @@auth_model = 'shop' # rubocop:disable Style/ClassVars
35
+
36
+ def self.use_rails_app_controller=(value)
37
+ @use_rails_app_controller = value
38
+ end
19
39
 
20
40
  class << self
21
41
  def configuration
@@ -2,7 +2,7 @@
2
2
 
3
3
  module BeyondCanvas
4
4
  class Configuration # :nodoc:
5
- attr_accessor :site_title, :site_logo, :favicon, :skip_webpacker
5
+ attr_accessor :site_title, :site_logo, :favicon, :skip_webpacker, :encryption_key, :blind_index_key, :namespace
6
6
 
7
7
  include AssetRegistration
8
8
 
@@ -11,6 +11,9 @@ module BeyondCanvas
11
11
  @site_logo = nil
12
12
  @favicon = nil
13
13
  @skip_webpacker = false
14
+ @encryption_key = nil
15
+ @blind_index_key = nil
16
+ @namespace = '/'
14
17
  end
15
18
 
16
19
  def setup!
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'beyond_canvas/rails/routes'
4
+
3
5
  module BeyondCanvas
4
6
  class Engine < ::Rails::Engine # :nodoc:
5
7
  isolate_namespace BeyondCanvas
@@ -15,7 +17,9 @@ module BeyondCanvas
15
17
 
16
18
  config.before_initialize do
17
19
  ActiveSupport.on_load :action_controller do
20
+ include ::BeyondCanvas::Authentication
18
21
  include ::BeyondCanvas::LocaleManagement
22
+ include ::BeyondCanvas::ResourceManagement
19
23
  include ::BeyondCanvas::RequestValidation
20
24
  include ::BeyondCanvas::StatusCodes
21
25
 
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ module Models
5
+ module Authentication # :nodoc:
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ attr_accessor :code, :signature, :access_token_url
10
+
11
+ ##############################################################################
12
+ # Encrypted attribute configuration
13
+ ##############################################################################
14
+
15
+ attr_encrypted :beyond_api_url, key: [BeyondCanvas.configuration.encryption_key].pack('H*')
16
+ attr_encrypted :beyond_access_token, key: [BeyondCanvas.configuration.encryption_key].pack('H*')
17
+ attr_encrypted :beyond_refresh_token, key: [BeyondCanvas.configuration.encryption_key].pack('H*')
18
+
19
+ blind_index :beyond_api_url, key: [BeyondCanvas.configuration.blind_index_key].pack('H*')
20
+
21
+ ##############################################################################
22
+ # Validations
23
+ ##############################################################################
24
+
25
+ # Callback url params
26
+
27
+ validates :code,
28
+ presence: true,
29
+ on: :create
30
+ validates :signature,
31
+ presence: true,
32
+ on: :create
33
+ validates :access_token_url,
34
+ presence: true,
35
+ on: :create
36
+
37
+ # Database fields
38
+
39
+ validates :beyond_api_url,
40
+ presence: true
41
+ validates :beyond_access_token,
42
+ presence: true,
43
+ unless: -> { encrypted_beyond_access_token_was.blank? }
44
+ validates :beyond_refresh_token,
45
+ presence: true,
46
+ unless: -> { encrypted_beyond_refresh_token_was.blank? }
47
+
48
+ ##############################################################################
49
+ # Instance methods
50
+ ##############################################################################
51
+
52
+ #
53
+ # Get and save access_token and refresh_token using the authentication code
54
+ # NOTE: This method is used during the shop creation, as it is the only point
55
+ # we know about the authentication code
56
+ #
57
+ def authenticate
58
+ session = BeyondApi::Session.new(api_url: beyond_api_url)
59
+ session.token.create(code)
60
+ update(beyond_access_token: session.access_token,
61
+ beyond_refresh_token: session.refresh_token)
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ module Models
5
+ module Shop # :nodoc:
6
+ extend ActiveSupport::Concern
7
+ include BeyondCanvas::Models::Authentication
8
+ include BeyondCanvas::Models::Utils
9
+
10
+ included do
11
+ attr_accessor :api_url, :return_url
12
+
13
+ ##############################################################################
14
+ # Validations
15
+ ##############################################################################
16
+
17
+ # Callback url params
18
+
19
+ validates :api_url,
20
+ presence: true,
21
+ on: :create
22
+ validates :return_url,
23
+ presence: true,
24
+ on: :create
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ module Models
5
+ module Utils # :nodoc:
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ ##############################################################################
10
+ # Instance methods
11
+ ##############################################################################
12
+
13
+ #
14
+ # Generates a new access_token and refresh_token
15
+ #
16
+ def refresh_token
17
+ beyond_session = BeyondApi::Session.new(api_url: beyond_api_url, refresh_token: beyond_refresh_token)
18
+ beyond_session.token.refresh
19
+
20
+ update(beyond_access_token: beyond_session.access_token,
21
+ beyond_refresh_token: beyond_session.refresh_token)
22
+ end
23
+
24
+ #
25
+ # Generates a new access_token and refresh_token if they have expired
26
+ #
27
+ def refresh_token_if_needed
28
+ token_timestamp = JWT.decode(beyond_access_token, nil, false).first['exp']
29
+ current_timestamp = DateTime.now.to_i
30
+ return unless token_timestamp - current_timestamp <= 3600
31
+
32
+ refresh_token
33
+ end
34
+
35
+ #
36
+ # Returns a BeyondApi::Session object with api_url, access_token and refresh_token attributes
37
+ #
38
+ def to_session
39
+ BeyondApi::Session.new(api_url: beyond_api_url,
40
+ access_token: beyond_access_token,
41
+ refresh_token: beyond_refresh_token)
42
+ end
43
+
44
+ ##############################################################################
45
+ # Class methods
46
+ ##############################################################################
47
+
48
+ def self.find_session(id)
49
+ shop = find(id)
50
+ shop.to_session
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ class ParameterSanitizer # :nodoc:
5
+ DEFAULT_PERMITTED_ATTRIBUTES = %i[code signature return_url api_url access_token_url].freeze
6
+
7
+ def initialize(resource_name, params)
8
+ @params = params
9
+ @resource_name = resource_name
10
+ @permitted = DEFAULT_PERMITTED_ATTRIBUTES
11
+ end
12
+
13
+ def sanitize
14
+ permit_keys(default_params)
15
+ end
16
+
17
+ def permit(*keys)
18
+ @permitted.concat(keys)
19
+ end
20
+
21
+ private
22
+
23
+ def default_params
24
+ if hashable_resource_params?
25
+ @params.fetch(@resource_name)
26
+ else
27
+ empty_params
28
+ end
29
+ end
30
+
31
+ def hashable_resource_params?
32
+ @params[@resource_name].respond_to?(:permit)
33
+ end
34
+
35
+ def empty_params
36
+ ActionController::Parameters.new({})
37
+ end
38
+
39
+ def permit_keys(parameters)
40
+ parameters.permit(*@permitted)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionDispatch
4
+ module Routing
5
+ class Mapper # :nodoc:
6
+ def beyond_canvas_for(*resources)
7
+ mount BeyondCanvas::Engine => BeyondCanvas.configuration.namespace
8
+
9
+ resource_name, options = resources
10
+ BeyondCanvas.auth_model = resource_name.to_s.singularize
11
+ BeyondCanvas.use_rails_app_controller = options.present? && options[:controller].present?
12
+
13
+ set_routes(resource_name, options[:controller]) if BeyondCanvas.use_rails_app_controller
14
+ end
15
+
16
+ def set_routes(resource_name, controller)
17
+ resources resource_name, controller: controller
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeyondCanvas
4
- VERSION = '0.15.3.pre'
4
+ VERSION = '0.16.0.pre'
5
5
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/active_record'
4
+
5
+ module BeyondCanvas
6
+ module Generators
7
+ class AuthModelGenerator < ActiveRecord::Generators::Base # :nodoc:
8
+ desc 'Generates a model with the given name and provides a method to authenticate in Beyond Backend'
9
+
10
+ argument :attributes, type: :array, default: [], banner: 'field:type field:type'
11
+
12
+ source_root File.expand_path('templates', __dir__)
13
+
14
+ def copy_beyond_canvas_migration
15
+ migration_path = File.join('db', 'migrate')
16
+ migration_template 'migration.erb',
17
+ "#{migration_path}/beyond_canvas_create_#{table_name}.rb",
18
+ migration_version: migration_version
19
+ end
20
+
21
+ def generate_model
22
+ template 'model.erb', File.join('app', 'models', "#{file_path}.rb")
23
+ end
24
+
25
+ private
26
+
27
+ def rails5_and_up?
28
+ Rails::VERSION::MAJOR >= 5
29
+ end
30
+
31
+ def migration_version
32
+ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if rails5_and_up?
33
+ end
34
+
35
+ def migration_data
36
+ <<RUBY
37
+ t.string :encrypted_beyond_api_url, null: false
38
+ t.string :encrypted_beyond_api_url_iv, null: false
39
+ t.string :beyond_api_url_bidx, null: false
40
+
41
+ t.text :encrypted_beyond_access_token, null: true
42
+ t.text :encrypted_beyond_access_token_iv, null: true
43
+
44
+ t.text :encrypted_beyond_refresh_token, null: true
45
+ t.text :encrypted_beyond_refresh_token_iv, null: true
46
+ RUBY
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ class BeyondCanvasCreate<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
4
+ def change
5
+ create_table :<%= table_name %><%= primary_key_type %> do |t|
6
+ <%= migration_data -%>
7
+
8
+ <% attributes.each do |attribute| -%>
9
+ t.<%= attribute.type %> :<%= attribute.name %>
10
+ <% end -%>
11
+
12
+ t.timestamps null: false
13
+ end
14
+
15
+ add_index :<%= table_name %>, :encrypted_beyond_api_url_iv, unique: true
16
+ add_index :<%= table_name %>, :beyond_api_url_bidx, unique: true
17
+ add_index :<%= table_name %>, :encrypted_beyond_access_token_iv, unique: true
18
+ add_index :<%= table_name %>, :encrypted_beyond_refresh_token_iv, unique: true
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class <%= file_path.classify %> < ApplicationRecord
4
+ include BeyondCanvas::Models::Shop
5
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/active_record'
4
+
5
+ module BeyondCanvas
6
+ module Generators
7
+ class ControllerGenerator < Rails::Generators::Base # :nodoc:
8
+ desc 'Creates an inherited Beyond Canvas controller in the app/controllers folder'
9
+
10
+ argument :scope, required: true, desc: 'The scope to create the controller, e.g. shops, users'
11
+
12
+ source_root File.expand_path('templates', __dir__)
13
+
14
+ def create_controller
15
+ template 'controller.erb',
16
+ "app/controllers/#{scope}_controller.rb"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ class <%= scope.camelize %>Controller < BeyondCanvas::AuthenticationsController
4
+ # before_action :configure_params, only: [:create]
5
+
6
+ # def new
7
+ # super
8
+ # end
9
+
10
+ # def create
11
+ # super
12
+ # end
13
+
14
+ # private
15
+
16
+ # If you have extra params to permit, append them to the sanitizer.
17
+ # def configure_params
18
+ # beyond_canvas_parameter_sanitizer.permit(:attribute1, :attribute2)
19
+ # end
20
+
21
+ # The path used after creating the shop in the database
22
+ # def after_create_path
23
+ # resource.return_url
24
+ # end
25
+
26
+ # def handle_active_record_exception(exception)
27
+ # super
28
+ # end
29
+
30
+ # def handle_beyond_api_exception(exception)
31
+ # super
32
+ # end
33
+
34
+ # def handle_standard_error_exception(exception)
35
+ # super
36
+ # end
37
+ end
@@ -6,19 +6,17 @@ module BeyondCanvas
6
6
  desc 'Installs Beyond Canvas and generates the necessary files'
7
7
 
8
8
  class_option :skip_webpacker, type: :boolean, default: false, desc: 'Use Sprockets assets instead of Webpacker'
9
+ class_option :auth_model, type: :string, default: 'shop', desc: 'Authentication model'
9
10
 
10
11
  source_root File.expand_path('templates', __dir__)
11
12
 
12
13
  def copy_initializer
13
14
  @skip_webpacker = options[:skip_webpacker]
15
+ @auth_model = options[:auth_model]
14
16
 
15
17
  template 'beyond_canvas.rb.erb', 'config/initializers/beyond_canvas.rb'
16
18
  end
17
19
 
18
- def setup_routes
19
- route "mount BeyondCanvas::Engine => '/'"
20
- end
21
-
22
20
  def create_assets
23
21
  if options[:skip_webpacker]
24
22
  generate 'beyond_canvas:assets'
@@ -28,7 +26,19 @@ module BeyondCanvas
28
26
  end
29
27
 
30
28
  def install_beyond_api
31
- generate 'beyond_api:install'
29
+ generate 'beyond_canvas:beyond_api'
30
+ end
31
+
32
+ def generate_auth_model
33
+ generate "beyond_canvas:auth_model #{@auth_model}"
34
+ end
35
+
36
+ def setup_routes
37
+ route "beyond_canvas_for :#{@auth_model.pluralize}"
38
+ end
39
+
40
+ def copy_locale
41
+ copy_file '../../../../../config/locales/en.yml', 'config/locales/beyond_canvas.en.yml'
32
42
  end
33
43
  end
34
44
  end
@@ -37,4 +37,15 @@ BeyondCanvas.setup do |config|
37
37
  # You can switch to using Sprocket's asset pipeline here.
38
38
  #
39
39
  <% unless @skip_webpacker %># <% end %>config.skip_webpacker = <%= @skip_webpacker %>
40
+
41
+ # ==> Authentication with ePages Beyond API
42
+
43
+ # Default model is shop
44
+ #
45
+ config.encryption_key = '<%= SecureRandom.hex(32) %>'
46
+ config.blind_index_key = '<%= SecureRandom.hex(32) %>'
47
+
48
+ # ==> Mountable engine configuration
49
+ #
50
+ # config.namespace = '/'
40
51
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/active_record'
4
+
5
+ module BeyondCanvas
6
+ module Generators
7
+ class ViewsGenerator < Rails::Generators::Base # :nodoc:
8
+ desc 'Creates a view in the app/view folder'
9
+
10
+ argument :scope, required: true, desc: 'The scope to copy views to'
11
+
12
+ source_root File.expand_path('../../../../app/views/beyond_canvas/authentications', __dir__)
13
+
14
+ def create_view
15
+ copy_file 'new.html.erb', "app/views/#{scope}/new.html.erb"
16
+ end
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,29 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beyond_canvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.3.pre
4
+ version: 0.16.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unai Abrisketa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-18 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: attr_encrypted
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: beyond_api
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '0.8'
33
+ version: '0.11'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '0.8'
40
+ version: '0.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: blind_index
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: bourbon
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -207,9 +235,12 @@ files:
207
235
  - app/assets/stylesheets/beyond_canvas/utilities/_functions.scss
208
236
  - app/assets/stylesheets/beyond_canvas/utilities/_mixins.scss
209
237
  - app/controllers/beyond_canvas/application_controller.rb
238
+ - app/controllers/beyond_canvas/authentications_controller.rb
210
239
  - app/controllers/beyond_canvas/system_controller.rb
240
+ - app/controllers/concerns/beyond_canvas/authentication.rb
211
241
  - app/controllers/concerns/beyond_canvas/locale_management.rb
212
242
  - app/controllers/concerns/beyond_canvas/request_validation.rb
243
+ - app/controllers/concerns/beyond_canvas/resource_management.rb
213
244
  - app/controllers/concerns/beyond_canvas/status_codes.rb
214
245
  - app/form_builders/beyond_canvas/form_builder.rb
215
246
  - app/helpers/beyond_canvas/application_helper.rb
@@ -219,6 +250,7 @@ files:
219
250
  - app/javascript/beyond_canvas/initializers/flash.js
220
251
  - app/javascript/beyond_canvas/initializers/functions.js
221
252
  - app/javascript/beyond_canvas/initializers/inputs.js
253
+ - app/views/beyond_canvas/authentications/new.html.erb
222
254
  - app/views/beyond_canvas/custom/_public_head.html.erb
223
255
  - app/views/beyond_canvas/locales/_edit.html.erb
224
256
  - app/views/beyond_canvas/mailer/_button.html.erb
@@ -232,20 +264,32 @@ files:
232
264
  - app/views/layouts/beyond_canvas/public.html.erb
233
265
  - config/initializers/beyond_canvas/filter_parameter_logging.rb
234
266
  - config/initializers/beyond_canvas/form_utils.rb
267
+ - config/locales/en.yml
235
268
  - config/routes.rb
236
269
  - lib/beyond_canvas.rb
237
270
  - lib/beyond_canvas/asset_registration.rb
238
271
  - lib/beyond_canvas/configuration.rb
239
272
  - lib/beyond_canvas/engine.rb
273
+ - lib/beyond_canvas/models/authentication.rb
274
+ - lib/beyond_canvas/models/shop.rb
275
+ - lib/beyond_canvas/models/utils.rb
276
+ - lib/beyond_canvas/parameter_sanitizer.rb
277
+ - lib/beyond_canvas/rails/routes.rb
240
278
  - lib/beyond_canvas/version.rb
241
279
  - lib/generators/beyond_canvas/assets/assets_generator.rb
242
280
  - lib/generators/beyond_canvas/assets/templates/beyond_canvas.js
243
281
  - lib/generators/beyond_canvas/assets/templates/beyond_canvas.scss
282
+ - lib/generators/beyond_canvas/auth_model/auth_model_generator.rb
283
+ - lib/generators/beyond_canvas/auth_model/templates/migration.erb
284
+ - lib/generators/beyond_canvas/auth_model/templates/model.erb
244
285
  - lib/generators/beyond_canvas/beyond_api/beyond_api_generator.rb
286
+ - lib/generators/beyond_canvas/controller/controller_generator.rb
287
+ - lib/generators/beyond_canvas/controller/templates/controller.erb
245
288
  - lib/generators/beyond_canvas/custom_styles/custom_styles_generator.rb
246
289
  - lib/generators/beyond_canvas/custom_styles/templates/beyond_canvas_custom_styles.sass
247
290
  - lib/generators/beyond_canvas/install/install_generator.rb
248
291
  - lib/generators/beyond_canvas/install/templates/beyond_canvas.rb.erb
292
+ - lib/generators/beyond_canvas/views/views_generator.rb
249
293
  - lib/generators/beyond_canvas/webpacker/plugins/jquery.js
250
294
  - lib/generators/beyond_canvas/webpacker/templates/beyond_canvas.js
251
295
  - lib/generators/beyond_canvas/webpacker/templates/beyond_canvas.scss
@@ -269,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
313
  - !ruby/object:Gem::Version
270
314
  version: 1.3.1
271
315
  requirements: []
272
- rubygems_version: 3.0.1
316
+ rubygems_version: 3.0.3
273
317
  signing_key:
274
318
  specification_version: 4
275
319
  summary: Open-source framework that provides CSS styles