dscf-core 0.3.1 → 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: '049d90d63eb4196e4b7d15ae1208485d7d09fe4a29a29ed920010b8ebcc6a312'
4
- data.tar.gz: 768e5835fd1172552db3548fd675b2a2a3a8b332c6e3bda211ec253f1e0c27e1
3
+ metadata.gz: 99924a8190ed67a7540dd59d895d83d1925acb7ace7b16f8928d22e96a95e3cf
4
+ data.tar.gz: 704c08cb732f2fc1a6212bf4270afea4bbeed5e637ee0fb5950f63852c7eb893
5
5
  SHA512:
6
- metadata.gz: 3ed7b66f6f68b8d51dec4bf2d74561b7c8f2f793e7724bd9aa578c91b6f4f870fb6818afed28d2f1b3b4c84a23b2309f00a254c96896555c57763018624a9daf
7
- data.tar.gz: 26f208c4e989045dc55ad983034742a4768b4659602ef7b646f2e6c192ab26ce09ddb78a734884d7becb75eeb16d30ebe6e282a9396ae27e06c47fd2869c1c24
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
- user = AuthService.authenticate_user(params[:email_or_phone], params[:password])
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)
@@ -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
- return [] unless object.files.attached?
12
-
13
- object.files.map { |file| url_for(file) }
10
+ object.file_urls
14
11
  end
15
12
  end
16
13
  end
@@ -52,6 +52,8 @@ module Dscf
52
52
  private
53
53
 
54
54
  def find_user_by_email_or_phone(email_or_phone)
55
+ return nil if email_or_phone.blank?
56
+
55
57
  if email_or_phone.include?("@")
56
58
  User.find_by(email: email_or_phone)
57
59
  else
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Core
3
- VERSION = "0.3.1".freeze
3
+ VERSION = "0.3.2".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dscf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat