virtuatable-core 1.6.0.dev1 → 1.6.0.dev5

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: d04349e236702f20e0c4a2542187eb4d1a0ef59d6ff4b44f90ff7d1a2484f783
4
- data.tar.gz: f1e41d1f2b0a89c2851d617c2642222351a96cda77f0baeefed1a67eb98150d5
3
+ metadata.gz: c37ed6a8ec0a2a23b4ad7eecd2e875c102e30dd245607b949161d757335917b2
4
+ data.tar.gz: 3ac1143c4174f372cc91c34399340742923a11132cfdff914f301993905682fe
5
5
  SHA512:
6
- metadata.gz: d1a87bca549bdc10d5f9dbee7c483051a0af0d7ec0cfb5594051a64b617e07fe8e32f8fcb7231398a078e4ca30d4d51e3434eb703bbdf5f5790474da897d8c6d
7
- data.tar.gz: 910921c135060a8b78065c146e41ccc6e13f32e24ed75bafd4b3f507058ccb22a47c88f75ecfff991831c65382e1c56c3971124b07855e7e7513242871eec184
6
+ metadata.gz: 981c8f5f7d41113ed22fe44a5187813d781a9ce5c75be0bcfaa5f2078f16958212b8064c982104ca55adff9e9c2c70e7cb407ebb45094ced051f1ea0a08154a6
7
+ data.tar.gz: 212dd8eac364a4e113c0da59b13125962c2da476f8e84b5112dfa53493ab4e9349a6d6ad3c77dc0d51c3a870aaf1c39eeef558fe91292cef3d00c68ab45b7c04
@@ -0,0 +1,9 @@
1
+ module Core
2
+ module Decorators
3
+ class Authorization < Core::Decorators::Base
4
+ def to_h
5
+ { code: object.code }
6
+ end
7
+ end
8
+ end
9
+ end
@@ -2,6 +2,7 @@ module Core
2
2
  module Decorators
3
3
  autoload :Account, 'core/decorators/account'
4
4
  autoload :Application, 'core/decorators/application'
5
+ autoload :Authorization, 'core/decorators/authorization'
5
6
  autoload :Base, 'core/decorators/base'
6
7
  autoload :Campaign, 'core/decorators/campaign'
7
8
  autoload :Session, 'core/decorators/session'
@@ -8,6 +8,16 @@ module Core
8
8
  class Authorizations < Core::Services::Base
9
9
  include Singleton
10
10
 
11
+ def create_from_session(session_id: nil, client_id: nil, **ignored)
12
+ session = Core.svc.sessions.get_by_id(session_id: session_id)
13
+ application = Core.svc.applications.get_by_id(client_id: client_id)
14
+ authorization = Core::Models::OAuth::Authorization.create(
15
+ account: session.account,
16
+ application: application
17
+ )
18
+ Core::Decorators::Authorization.new(authorization)
19
+ end
20
+
11
21
  # Gets the authorization code corresponding to the provided value if it is linked to the
12
22
  # application matching the provided credentials. Otherwise it raises errors.
13
23
  #
@@ -42,7 +52,7 @@ module Core
42
52
  authorization = Core::Models::OAuth::Authorization.find_by(code: authorization_code)
43
53
  raise unknown_err(field: 'authorization_code') if authorization.nil?
44
54
 
45
- authorization
55
+ Core::Decorators::Authorization.new(authorization)
46
56
  end
47
57
 
48
58
  private
@@ -28,6 +28,7 @@ module Core
28
28
  account: account,
29
29
  token: SecureRandom.uuid
30
30
  )
31
+ Decorators::Session.new(session)
31
32
  end
32
33
 
33
34
  # Gets the session by its unique identifier.
data/lib/core/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Core
4
- VERSION = '1.6.0.dev1'
4
+ VERSION = '1.6.0.dev5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtuatable-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0.dev1
4
+ version: 1.6.0.dev5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Courtois
@@ -280,16 +280,16 @@ dependencies:
280
280
  name: draper
281
281
  requirement: !ruby/object:Gem::Requirement
282
282
  requirements:
283
- - - ">="
283
+ - - '='
284
284
  - !ruby/object:Gem::Version
285
- version: '0'
285
+ version: 4.0.2
286
286
  type: :runtime
287
287
  prerelease: false
288
288
  version_requirements: !ruby/object:Gem::Requirement
289
289
  requirements:
290
- - - ">="
290
+ - - '='
291
291
  - !ruby/object:Gem::Version
292
- version: '0'
292
+ version: 4.0.2
293
293
  description: This gem holds the model layer for my table-top RPG games application.
294
294
  email: courtois.vincent@outlook.com
295
295
  executables: []
@@ -302,6 +302,7 @@ files:
302
302
  - lib/core/decorators.rb
303
303
  - lib/core/decorators/account.rb
304
304
  - lib/core/decorators/application.rb
305
+ - lib/core/decorators/authorization.rb
305
306
  - lib/core/decorators/base.rb
306
307
  - lib/core/decorators/campaign.rb
307
308
  - lib/core/decorators/session.rb