dscf-core 0.3.0 → 0.3.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 99924a8190ed67a7540dd59d895d83d1925acb7ace7b16f8928d22e96a95e3cf
|
|
4
|
+
data.tar.gz: 704c08cb732f2fc1a6212bf4270afea4bbeed5e637ee0fb5950f63852c7eb893
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f54ec142983b8d836d20f2342b2d858abcf8c4cbc3588329a164e5363eb96ef6b5a5c474582b9ca19e7eabfdcc9cab999606b19e78159662c18d8099d16dc0ce
|
|
7
|
+
data.tar.gz: 4ece59364b2199d9d99511b412306d9b177c6ba412975be439e5a6b0cb62e63fb0596f4842951eaea7809f42fe5a6b84676c7028fe5414706d4be148be7e5439
|
|
@@ -8,7 +8,12 @@ module Dscf
|
|
|
8
8
|
|
|
9
9
|
def login
|
|
10
10
|
skip_authorization
|
|
11
|
-
|
|
11
|
+
email_or_phone = params[:email_or_phone].presence || params.dig(:auth, :email_or_phone).presence
|
|
12
|
+
password = params[:password].presence || params.dig(:auth, :password).presence
|
|
13
|
+
|
|
14
|
+
return render_error("auth.errors.missing_credentials", status: :bad_request) unless email_or_phone && password
|
|
15
|
+
|
|
16
|
+
user = AuthService.authenticate_user(email_or_phone, password)
|
|
12
17
|
|
|
13
18
|
if user&.valid_for_authentication?
|
|
14
19
|
tokens = sign_in(user, request)
|
|
@@ -119,11 +124,11 @@ module Dscf
|
|
|
119
124
|
end
|
|
120
125
|
|
|
121
126
|
def assign_default_role(user)
|
|
122
|
-
role = Role.find_or_create_by!(
|
|
123
|
-
r.
|
|
127
|
+
role = Role.find_or_create_by!(code: "USER") do |r|
|
|
128
|
+
r.name = "User"
|
|
124
129
|
end
|
|
125
130
|
|
|
126
|
-
UserRole.
|
|
131
|
+
UserRole.find_or_create_by!(user: user, role: role)
|
|
127
132
|
end
|
|
128
133
|
end
|
|
129
134
|
end
|
|
@@ -2,15 +2,12 @@ module Dscf
|
|
|
2
2
|
module Core
|
|
3
3
|
class DocumentSerializer < ActiveModel::Serializer
|
|
4
4
|
attributes :id, :document_type, :file_urls, :is_verified, :verified_at, :created_at, :updated_at
|
|
5
|
-
include Rails.application.routes.url_helpers
|
|
6
5
|
|
|
7
6
|
belongs_to :documentable, polymorphic: true
|
|
8
7
|
belongs_to :verified_by, polymorphic: true, optional: true
|
|
9
8
|
|
|
10
9
|
def file_urls
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
object.files.map { |file| url_for(file) }
|
|
10
|
+
object.file_urls
|
|
14
11
|
end
|
|
15
12
|
end
|
|
16
13
|
end
|
data/lib/dscf/core/version.rb
CHANGED