morpho 1.2.0 → 1.2.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/api/morpho/entities/user.rb +0 -1
- data/app/api/morpho/resources/activations.rb +9 -4
- data/app/api/morpho/resources/externals.rb +8 -2
- data/app/api/morpho/resources/passwords.rb +9 -4
- data/app/api/morpho/resources/tokens.rb +19 -5
- data/app/api/morpho/resources/unlocks.rb +10 -5
- data/app/api/morpho/resources/users.rb +8 -3
- data/app/concepts/morpho/contracts/user/deliver_email.rb +13 -0
- data/app/concepts/morpho/contracts/user/external_sign_in.rb +17 -0
- data/app/concepts/morpho/contracts/user/refresh_token.rb +13 -0
- data/app/concepts/morpho/contracts/user/resend_activation_email.rb +8 -0
- data/app/concepts/morpho/contracts/user/resend_unlock_email.rb +8 -0
- data/app/concepts/morpho/contracts/user/send_reset_password_email.rb +8 -0
- data/app/concepts/morpho/contracts/user/sign_in.rb +15 -0
- data/app/concepts/morpho/contracts/user/sign_up.rb +25 -0
- data/app/concepts/morpho/operations/base/create.rb +14 -0
- data/app/concepts/morpho/operations/base/delete.rb +16 -0
- data/app/concepts/morpho/operations/base/fetch.rb +106 -0
- data/app/concepts/morpho/operations/base/find.rb +55 -0
- data/app/concepts/morpho/operations/base/form.rb +84 -0
- data/app/concepts/morpho/operations/base/update.rb +19 -0
- data/app/concepts/morpho/operations/user/deliver_email.rb +38 -0
- data/app/concepts/morpho/operations/user/external_sign_in.rb +38 -0
- data/app/concepts/morpho/operations/user/generate_token.rb +33 -0
- data/app/concepts/morpho/operations/user/refresh_token.rb +41 -0
- data/app/concepts/morpho/operations/user/resend_activation_email.rb +31 -0
- data/app/concepts/morpho/operations/user/resend_unlock_email.rb +31 -0
- data/app/concepts/morpho/operations/user/send_reset_password_email.rb +30 -0
- data/app/concepts/morpho/operations/user/sign_in.rb +49 -0
- data/app/concepts/morpho/operations/user/sign_up.rb +8 -0
- data/app/models/morpho/user.rb +6 -2
- data/config/locales/morpho.en.yml +2 -0
- data/config/locales/morpho.es.yml +2 -0
- data/lib/generators/morpho/install/templates/app/api/morpho/api.rb +12 -2
- data/lib/generators/morpho/install/templates/config/initializers/morpho.rb +2 -1
- data/lib/morpho/configuration.rb +2 -0
- data/lib/morpho/engine.rb +1 -6
- data/lib/morpho/version.rb +1 -1
- metadata +26 -17
- data/app/concepts/morpho/user/contract/activate.rb +0 -8
- data/app/concepts/morpho/user/contract/external_sign_in.rb +0 -12
- data/app/concepts/morpho/user/contract/refresh_token.rb +0 -8
- data/app/concepts/morpho/user/contract/reset_password.rb +0 -8
- data/app/concepts/morpho/user/contract/sign_in.rb +0 -10
- data/app/concepts/morpho/user/contract/sign_up.rb +0 -22
- data/app/concepts/morpho/user/contract/unlock.rb +0 -8
- data/app/concepts/morpho/user/operation/activate.rb +0 -42
- data/app/concepts/morpho/user/operation/external_sign_in.rb +0 -70
- data/app/concepts/morpho/user/operation/refresh_token.rb +0 -37
- data/app/concepts/morpho/user/operation/reset_password.rb +0 -40
- data/app/concepts/morpho/user/operation/sign_in.rb +0 -73
- data/app/concepts/morpho/user/operation/sign_up.rb +0 -32
- data/app/concepts/morpho/user/operation/unlock.rb +0 -42
@@ -1,40 +0,0 @@
|
|
1
|
-
module Morpho
|
2
|
-
class User::Operation::ResetPassword < Trailblazer::Operation
|
3
|
-
pass :validate!
|
4
|
-
pass :find!
|
5
|
-
pass :check!
|
6
|
-
pass :reset_password_email!
|
7
|
-
|
8
|
-
def validate!(options, **)
|
9
|
-
options['contract'] = Morpho::User::Contract::ResetPassword.new(OpenStruct.new)
|
10
|
-
|
11
|
-
unless options['contract'].validate(options['data'])
|
12
|
-
raise Morpho::Exceptions::StandardError.new(
|
13
|
-
errors: options['contract'].errors
|
14
|
-
)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def find!(options, **)
|
19
|
-
options['model'] = Morpho::User.find_by(email: options['data']['email'])
|
20
|
-
|
21
|
-
if options['model'].nil?
|
22
|
-
raise Morpho::Exceptions::StandardError.new(
|
23
|
-
status: 404
|
24
|
-
)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def check!(options, **)
|
29
|
-
if options['model'].external?
|
30
|
-
raise Morpho::Exceptions::StandardError.new(
|
31
|
-
status: 405
|
32
|
-
)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def reset_password_email!(options, **)
|
37
|
-
options['model'].deliver_reset_password_instructions!
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
module Morpho
|
2
|
-
class User::Operation::SignIn < Trailblazer::Operation
|
3
|
-
pass :validate!
|
4
|
-
pass :find!
|
5
|
-
pass :check_active!
|
6
|
-
pass :check_unlocked!
|
7
|
-
pass :check_password!
|
8
|
-
pass :generate_refresh_token!
|
9
|
-
pass :register_last_login_activity!
|
10
|
-
pass :authentication_token!
|
11
|
-
|
12
|
-
def validate!(options, **)
|
13
|
-
options['contract'] = Morpho::User::Contract::SignIn.new(OpenStruct.new)
|
14
|
-
|
15
|
-
unless options['contract'].validate(options['data'])
|
16
|
-
raise Morpho::Exceptions::StandardError.new(
|
17
|
-
errors: options['contract'].errors
|
18
|
-
)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def find!(options, **)
|
23
|
-
options['model'] = Morpho::User.find_by(email: options['data']['email'])
|
24
|
-
|
25
|
-
if options['model'].nil?
|
26
|
-
raise Morpho::Exceptions::StandardError.new(
|
27
|
-
message: I18n.t('morpho.api.messages.sign_in.email_not_exists'),
|
28
|
-
status: 404
|
29
|
-
)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def check_active!(options, **)
|
34
|
-
unless options['model'].active?
|
35
|
-
raise Morpho::Exceptions::StandardError.new(
|
36
|
-
message: I18n.t('morpho.api.messages.sign_in.account_not_confirmed'),
|
37
|
-
status: 403
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def check_unlocked!(options, **)
|
43
|
-
unless options['model'].unlocked?
|
44
|
-
raise Morpho::Exceptions::StandardError.new(
|
45
|
-
message: I18n.t('morpho.api.messages.sign_in.account_locked'),
|
46
|
-
status: 423
|
47
|
-
)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def check_password!(options, **)
|
52
|
-
unless options['model'].valid_password?(options['data']['password'])
|
53
|
-
options['model'].register_failed_login!
|
54
|
-
raise Morpho::Exceptions::StandardError.new(
|
55
|
-
message: I18n.t('morpho.api.messages.sign_in.bad_credentials'),
|
56
|
-
status: 401
|
57
|
-
)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def generate_refresh_token!(options, **)
|
62
|
-
options['model'].generate_refresh_token!
|
63
|
-
end
|
64
|
-
|
65
|
-
def register_last_login_activity!(options, **)
|
66
|
-
options['model'].register_last_login_activity!(options['ip'])
|
67
|
-
end
|
68
|
-
|
69
|
-
def authentication_token!(options, **)
|
70
|
-
options['token'] = ::Morpho::JWT::Payload.new(options['model'])
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module Morpho
|
2
|
-
class User::Operation::SignUp < Trailblazer::Operation
|
3
|
-
pass :validate!
|
4
|
-
pass :sync!
|
5
|
-
pass :save!
|
6
|
-
|
7
|
-
def validate!(options, **)
|
8
|
-
options['contract'] = Morpho::User::Contract::SignUp.new(Morpho::User.new)
|
9
|
-
|
10
|
-
unless options['contract'].validate(options['data'])
|
11
|
-
raise Morpho::Exceptions::StandardError.new(
|
12
|
-
errors: options['contract'].errors
|
13
|
-
)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def sync!(options, **)
|
18
|
-
options['contract'].sync
|
19
|
-
end
|
20
|
-
|
21
|
-
def save!(options, **)
|
22
|
-
options['model'] = options['contract'].model
|
23
|
-
options['model'].save
|
24
|
-
|
25
|
-
unless options['model'].persisted?
|
26
|
-
raise Morpho::Exceptions::StandardError.new(
|
27
|
-
errors: options['model'].errors
|
28
|
-
)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Morpho
|
2
|
-
class User::Operation::Unlock < Trailblazer::Operation
|
3
|
-
pass :validate!
|
4
|
-
pass :find!
|
5
|
-
pass :check!
|
6
|
-
pass :unlock_token_email!
|
7
|
-
|
8
|
-
def validate!(options, **)
|
9
|
-
options['contract'] = Morpho::User::Contract::Unlock.new(OpenStruct.new)
|
10
|
-
|
11
|
-
unless options['contract'].validate(options['data'])
|
12
|
-
raise Morpho::Exceptions::StandardError.new(
|
13
|
-
errors: options['contract'].errors
|
14
|
-
)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def find!(options, **)
|
19
|
-
options['model'] = Morpho::User.find_by(email: options['data']['email'])
|
20
|
-
|
21
|
-
if options['model'].nil?
|
22
|
-
raise Morpho::Exceptions::StandardError.new(
|
23
|
-
message: I18n.t('morpho.api.messages.unlock.email_not_exists'),
|
24
|
-
status: 404
|
25
|
-
)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def check!(options, **)
|
30
|
-
unless options['model'].login_locked?
|
31
|
-
raise Morpho::Exceptions::StandardError.new(
|
32
|
-
message: I18n.t('morpho.api.messages.unlock.account_not_locked'),
|
33
|
-
status: 405
|
34
|
-
)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def unlock_token_email!(options, **)
|
39
|
-
options['model'].resend_unlock_token_email!
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|