tramway-api 0.6.1.2 → 0.6.1.3

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: 1346da9664247ade1b7d23e1abe801b5047533f24521bf67570941486ba0df70
4
- data.tar.gz: 0f02451ab2c22f4aef2792be996109a84c4375bef132dc4080ccaef693e3ea0c
3
+ metadata.gz: 685306ba5192ad4a31885a29f774e3892f2b0e807c2d65323c3fb4aabdcb5fe4
4
+ data.tar.gz: 391fd9136d462647cc2b36e50a4cc1f8255fe3da57fd043b238dcc64cc90bcfb
5
5
  SHA512:
6
- metadata.gz: eaf679d627a6a7eeb7209f77240d4396fcb48c53ef3421c30a10d4e9f8422bcd2ccf562e2610d5f45d9e82ae5eef14ee5bc56c812efa696768eba288007941c2
7
- data.tar.gz: 825b079b76e078114cd54d3e9e202104e82ad5b20575f42c6eab913fed5f143156e0b5fb9f0363fc3120a9865184d78421e5ef1064525db8327d6132963687f2
6
+ metadata.gz: 2ec68fd04e3e14a4f85855942fed20f163f0eca33ad0acc1c487f5116059eb689962e4bb7af0a7cb1f1fd4f67fd06e2851919a70940c489b669e555e1249f3b1
7
+ data.tar.gz: 9aeae6018d957203230b6e45c01b0dd80ff857a0bb50b4d26590de8e7baccac7afa8889b8c63d5939c26a8d807bbe36d250edcb77fa8abf34ba547aecf8875bd
@@ -11,10 +11,18 @@ module Tramway
11
11
  render json: { data: [] }, status: :not_found
12
12
  end
13
13
 
14
+ def unauthorized
15
+ head :unauthorized
16
+ end
17
+
14
18
  protected
15
19
 
20
+ def authenticate_user
21
+ authenticate_for Tramway::Api.user_based_model
22
+ end
23
+
16
24
  def authenticate
17
- raise ActiveRecord::RecordNotFound unless entity.present? && entity.authenticate(auth_params[:password])
25
+ unauthorized unless entity.present? && entity.authenticate(auth_params[:password])
18
26
  end
19
27
 
20
28
  def auth_token
@@ -30,12 +38,12 @@ module Tramway
30
38
  if Tramway::Api.user_based_model.respond_to? :from_token_request
31
39
  Tramway::Api.user_based_model.from_token_request request
32
40
  else
33
- Tramway::Api.user_based_model.find_by email: auth_params[:email]
41
+ params[:auth] && Tramway::Api.user_based_model.find_by(email: auth_params[:email])
34
42
  end
35
43
  end
36
44
 
37
45
  def auth_params
38
- params.require(:auth).permit :email, :password
46
+ params[:auth]&.permit :email, :password
39
47
  end
40
48
  end
41
49
  end
@@ -1,5 +1,5 @@
1
1
  module Tramway
2
2
  module Api
3
- VERSION = '0.6.1.2'
3
+ VERSION = '0.6.1.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1.2
4
+ version: 0.6.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-01 00:00:00.000000000 Z
11
+ date: 2019-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: knock