arkaan 0.9.1 → 0.9.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
  SHA1:
3
- metadata.gz: 13d512b8386f5114378052bbcd061e1b4bf36905
4
- data.tar.gz: 1f63966434538ee43dba1dcac66f386cefc78bce
3
+ metadata.gz: d8f1cc45c3466267661dbc71dfec5bb2fd5a93dd
4
+ data.tar.gz: 8f441eb09926b3d324309b7f85bb47e51a483ec3
5
5
  SHA512:
6
- metadata.gz: a3ad1ffea6d69a1ab234745fbdb62584055d2ff70608bf2f22efa6c275134438dbcaa74eb0fe871338224020a12a3a1f6ce78ae084665e7bdf0a4df2f312f402
7
- data.tar.gz: 567c6071c55a76eae530a2ef3b176ec8aa1009c380970c4916a12bb19b203a07538324e168ed18d1b64796ec6d3a10fc83b31cc65e55c7b75de52edec4e854c9
6
+ metadata.gz: f3f8a8e9b52b9158158856d2ae205b7a1552993680f9cfee14098f275350da40bc618abb597698bf0d14a6c22cce31ad1fa3e42ebf050bbf4af426b4e788aaf6
7
+ data.tar.gz: c62378408fc1c9bccc5c1e4f6a2f442ed90cdfa5ddfbfc07d8542f66aef2775ea20ee2ccea724bdcc54991724916dcf98cfaba993f505480ea998c18b9ce9a0e
@@ -69,6 +69,18 @@ module Arkaan
69
69
  end
70
70
  end
71
71
 
72
+ # Checks if the session ID is given in the parameters and if the session exists.
73
+ # @param action [String] the action used to get the errors from the errors file.
74
+ # @return [Arkaan::Authentication::Session] the session when it exists.
75
+ def check_session(action)
76
+ check_presence('session_id', route: action)
77
+ session = Arkaan::Authentication::Session.where(token: params['session_id']).first
78
+ if session.nil?
79
+ custom_error(404, "#{action}.session_id.unknown")
80
+ end
81
+ return session
82
+ end
83
+
72
84
  # Adds the parsed body to the parameters, overwriting the parameters of the querystring with the values
73
85
  # of the SON body if they have similar keys.
74
86
  def add_body_to_params
@@ -101,6 +113,13 @@ module Arkaan
101
113
  field = messages.keys.first
102
114
  custom_error(400, "#{route}.#{field}.#{messages[field].first}")
103
115
  end
116
+
117
+ # Select parameters in the params hash, by its keys.
118
+ # @param fields [Array<String>] the keys to select in the params hash.
119
+ # @return [Hash] the selected chunk of the params hash.
120
+ def select_params(*fields)
121
+ return params.select { |key, value| fields.include?(key) }
122
+ end
104
123
  end
105
124
  end
106
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arkaan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Courtois