cats_core 1.1.20 → 1.1.21
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/cats/core/users_controller.rb +32 -2
- data/lib/cats/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 106712bfb38bd512ae9d06d20301aa81a5a199bb6522728cddcf6c1d688fe444
|
4
|
+
data.tar.gz: 80cf7130c7cbbb47bcf4120c021e54aa2e9eb7bf5578260664339a6cbca18e78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1741bedb659f842852f836dd020c79f45d4ec901f8e076be97007c06fec9a69cb5793ac7612a46b08e9fd06b92b6892bebb2baa39cb0d49b1a48bffba9c93f48
|
7
|
+
data.tar.gz: 7fb859382f5faf676437e39cdb7f64c0201a47bb7b9409dd4d41a8ec5e30d13713415f21a04a2b8e2c7fd40c0315c800d1dd64d5277ea846ff279357486a9a4f
|
@@ -3,7 +3,7 @@ module Cats
|
|
3
3
|
class UsersController < ApplicationController
|
4
4
|
include Common
|
5
5
|
|
6
|
-
before_action :set_user, only: %i[roles assign_role stores warehouse hub]
|
6
|
+
before_action :set_user, only: %i[update roles assign_role stores warehouse hub]
|
7
7
|
|
8
8
|
def index
|
9
9
|
users = Cats::Core::User.joins(:application_module)
|
@@ -11,6 +11,36 @@ module Cats
|
|
11
11
|
render json: { success: true, data: serialize(users) }
|
12
12
|
end
|
13
13
|
|
14
|
+
def create
|
15
|
+
prefix = model_params[:application_prefix]
|
16
|
+
application_module = Cats::Core::ApplicationModule.find_by(prefix: prefix)
|
17
|
+
|
18
|
+
obj = Cats::Core::User.new(model_params.except(:application_prefix))
|
19
|
+
obj.application_module = application_module
|
20
|
+
if obj.save
|
21
|
+
render json: { success: true, data: serialize(obj) }, status: :created
|
22
|
+
else
|
23
|
+
render json: { success: false, error: obj.errors.full_messages[0] }, status: :unprocessable_entity
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
if model_params[:application_prefix]
|
29
|
+
prefix = model_params[:application_prefix]
|
30
|
+
application_module = Cats::Core::ApplicationModule.find_by(prefix: prefix)
|
31
|
+
@user.assign_attributes(model_params.except(:application_prefix))
|
32
|
+
@user.application_module = application_module
|
33
|
+
else
|
34
|
+
@user.assign_attributes(model_params)
|
35
|
+
end
|
36
|
+
|
37
|
+
if @user.save
|
38
|
+
render json: { success: true, data: serialize(@user) }
|
39
|
+
else
|
40
|
+
render json: { success: false, error: @user.errors.full_messages[0] }, status: :unprocessable_entity
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
14
44
|
def roles
|
15
45
|
data = ActiveModelSerializers::SerializableResource.new(@user.roles)
|
16
46
|
render json: { success: true, data: data }
|
@@ -47,7 +77,7 @@ module Cats
|
|
47
77
|
def model_params
|
48
78
|
params.require(:payload).permit(
|
49
79
|
:first_name, :last_name, :email, :phone_number, :active, :password, :password_confirmation, :details,
|
50
|
-
:
|
80
|
+
:application_prefix
|
51
81
|
)
|
52
82
|
end
|
53
83
|
end
|
data/lib/cats/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cats_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|