linked_rails-auth 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/linked_rails/auth/otp_base.rb +3 -1
- data/app/policies/linked_rails/auth/registration_policy.rb +2 -0
- data/app/serializers/linked_rails/auth/registration_serializer.rb +2 -0
- data/lib/generators/linked_rails/auth/install_generator.rb +22 -17
- data/lib/generators/linked_rails/auth/templates/migration.rb.erb +1 -1
- data/lib/linked_rails/auth/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdac2ac7b1c19172bd134b16bb0a68b37d0e3554dbe2fa81758a8979ca978b16
|
4
|
+
data.tar.gz: f5a06a7413a6ea914343bb2e30c4777768772ecbde68550f3ac7185cdc346438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a74b845b028974e126b38cfc146869118d090337d9fde50558135294e9e9b377484e9a00f27855976fe0e1ebe42ce0e87992706f25f4199cbd1cabb30ae012ac
|
7
|
+
data.tar.gz: 99e7c1594200bcd42df838e537af3071f3664e855500041d781aeda362e7f7c77c620dbbb52bac74f8d4b329ed814994eeb160e37e685783913fca83f0f7f807
|
@@ -14,7 +14,9 @@ module LinkedRails
|
|
14
14
|
include OtpHelper
|
15
15
|
|
16
16
|
has_one_time_password
|
17
|
-
|
17
|
+
# rubocop:disable Rails/ReflectionClassName
|
18
|
+
belongs_to :owner, class_name: LinkedRails.class_variable_get(:@@otp_owner_class)
|
19
|
+
# rubocop:enable Rails/ReflectionClassName
|
18
20
|
validates :owner, presence: true
|
19
21
|
|
20
22
|
attr_accessor :encoded_session, :otp_attempt
|
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
module LinkedRails
|
4
4
|
module Auth
|
5
|
+
# rubocop:disable Layout/LineLength
|
5
6
|
class RegistrationPolicy < Pundit::PolicyFinder.new(LinkedRails.user_class).policy || LinkedRails.policy_parent_class
|
7
|
+
# rubocop:enable Layout/LineLength
|
6
8
|
permit_attributes %i[email password password_confirmation redirect_url]
|
7
9
|
|
8
10
|
def create?
|
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
module LinkedRails
|
4
4
|
module Auth
|
5
|
+
# rubocop:disable Layout/LineLength
|
5
6
|
class RegistrationSerializer < RDF::Serializers.serializer_for(LinkedRails.user_class) || LinkedRails.serializer_parent_class
|
7
|
+
# rubocop:enable Layout/LineLength
|
6
8
|
attribute :email, predicate: Vocab.schema.email, datatype: RDF::XSD[:string]
|
7
9
|
attribute :password, predicate: Vocab.ontola[:password], datatype: RDF::XSD[:string]
|
8
10
|
attribute :password_confirmation, predicate: Vocab.ontola[:passwordConfirmation], datatype: RDF::XSD[:string]
|
@@ -1,35 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'rails/generators'
|
4
|
+
require 'rails/generators/active_record'
|
5
5
|
|
6
6
|
module LinkedRails
|
7
7
|
module Auth
|
8
|
-
class InstallGenerator < ::Rails::Generators::Base
|
8
|
+
class InstallGenerator < ::Rails::Generators::Base # rubocop:disable Metrics/ClassLength
|
9
9
|
include ::Rails::Generators::Migration
|
10
|
-
source_root File.expand_path(
|
11
|
-
desc
|
10
|
+
source_root File.expand_path('templates', __dir__)
|
11
|
+
desc 'Installs LinkedRails Auth.'
|
12
12
|
|
13
|
-
def install
|
14
|
-
template
|
15
|
-
template
|
16
|
-
route
|
13
|
+
def install # rubocop:disable Metrics/MethodLength
|
14
|
+
template 'doorkeeper_jwt_initializer.rb', 'config/initializers/doorkeeper_jwt.rb'
|
15
|
+
template 'locales.yml', 'config/locales/linked_rails_auth.en.yml'
|
16
|
+
route 'use_linked_rails_auth'
|
17
17
|
|
18
18
|
migration_template(
|
19
|
-
|
20
|
-
|
19
|
+
'migration.rb.erb',
|
20
|
+
'db/migrate/install_linked_rails_auth.rb',
|
21
21
|
migration_version: migration_version
|
22
22
|
)
|
23
23
|
update_user_model
|
24
24
|
insert_doorkeeper
|
25
25
|
create_doorkeeper_app
|
26
26
|
|
27
|
-
readme
|
27
|
+
readme 'README'
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
-
def create_doorkeeper_app
|
32
|
+
def create_doorkeeper_app # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
33
33
|
if Doorkeeper::Application.any?
|
34
34
|
Rails.logger.info('Skipping Doorkeeper app creation, already exists')
|
35
35
|
|
@@ -67,7 +67,7 @@ module LinkedRails
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
def insert_doorkeeper
|
70
|
+
def insert_doorkeeper # rubocop:disable Metrics/MethodLength
|
71
71
|
file = 'config/initializers/doorkeeper.rb'
|
72
72
|
data = "api_only\n"\
|
73
73
|
"base_controller 'ApplicationController'\n"\
|
@@ -116,14 +116,14 @@ module LinkedRails
|
|
116
116
|
request.env['warden'].logout
|
117
117
|
user
|
118
118
|
end
|
119
|
-
|
119
|
+
FOO
|
120
120
|
end
|
121
121
|
|
122
122
|
def inject_controller_include
|
123
123
|
sentinel = /LinkedRails::Controller\n/m
|
124
124
|
in_root do
|
125
125
|
inject_into_file(
|
126
|
-
|
126
|
+
'app/controllers/application_controller.rb',
|
127
127
|
optimize_indentation('include LinkedRails::Auth::AuthHelper', 2),
|
128
128
|
after: sentinel
|
129
129
|
)
|
@@ -142,7 +142,12 @@ module LinkedRails
|
|
142
142
|
def update_user_model
|
143
143
|
file = 'app/models/user.rb'
|
144
144
|
no_guest = "\ndef guest?\n false\nend"
|
145
|
-
inject_into_file
|
145
|
+
inject_into_file(
|
146
|
+
file,
|
147
|
+
optimize_indentation(no_guest, 2),
|
148
|
+
after: ":recoverable, :rememberable, :validatable\n",
|
149
|
+
verbose: false
|
150
|
+
)
|
146
151
|
end
|
147
152
|
|
148
153
|
class << self
|