arkaan 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arkaan/utils/controller.rb +19 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f1cc45c3466267661dbc71dfec5bb2fd5a93dd
|
4
|
+
data.tar.gz: 8f441eb09926b3d324309b7f85bb47e51a483ec3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|