ecom_core 1.1.0 → 1.1.1
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 +4 -4
- data/app/controllers/ecom/core/access_controller.rb +8 -1
- data/app/models/ecom/core/user.rb +4 -0
- data/lib/ecom/core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0c28baf17d2c00ff282fba227a6cf7c10d4c6f11507e773214d3d82df2477e
|
4
|
+
data.tar.gz: 00e5b91dd8f598b92353923d80750deb193f627cec91e5563a85de6c770e25a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7ea275f8bc129cc1490ca5f2b6a4f90d7e631dabb4d6fb0e9af31f625f1e8fa4538caa6362dac463cd86db86ee3e2304b29a0959e4471cc73578b207bf6f003
|
7
|
+
data.tar.gz: 39d5157a5bb77483d59124289439d52ac94f2a0d37f53c486727727da1f14b83380bdd0afbffa69fa640150fff80dadf805404fef87583c48a7ca39cb3f3a8f1
|
@@ -4,13 +4,20 @@ module Ecom
|
|
4
4
|
skip_before_action :authenticate, only: [:login]
|
5
5
|
|
6
6
|
def login
|
7
|
+
app_code = Rails.configuration.app_code
|
7
8
|
user = User.find_by(email: auth_params[:email])
|
9
|
+
|
8
10
|
if user
|
9
11
|
if user.authenticate(auth_params[:password])
|
10
|
-
roles = user.
|
12
|
+
roles = user.roles_for_module(app_code).each_with_object([]) do |role, result|
|
11
13
|
result << role.name
|
12
14
|
end
|
13
15
|
|
16
|
+
if roles.count <= 0
|
17
|
+
render json: { error: 'User has no roles in this application.' }, status: :unprocessable_entity
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
14
21
|
payload = { id: user.id, email: user.email, name: user.full_name, roles: roles }
|
15
22
|
jwt = TokenAuthService.issue(payload)
|
16
23
|
render json: { token: jwt, user: payload, error: nil }
|
data/lib/ecom/core/version.rb
CHANGED