morpho 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -0
- data/app/api/morpho/entities/authentication_token.rb +1 -1
- data/app/api/morpho/entities/base.rb +7 -0
- data/app/api/morpho/entities/user.rb +2 -1
- data/app/api/morpho/entities/user_sign_in.rb +1 -1
- data/app/api/morpho/entities/user_sign_up.rb +1 -1
- data/app/api/morpho/resources/users.rb +2 -2
- data/app/mailers/morpho/application_mailer.rb +12 -0
- data/app/models/morpho/user.rb +4 -1
- data/app/views/morpho/user_mailer/activation_needed_email.html.erb +4 -7
- data/app/views/morpho/user_mailer/activation_needed_email.text.erb +4 -7
- data/app/views/morpho/user_mailer/activation_success_email.html.erb +4 -7
- data/app/views/morpho/user_mailer/activation_success_email.text.erb +4 -7
- data/app/views/morpho/user_mailer/reset_password_email.html.erb +4 -7
- data/app/views/morpho/user_mailer/reset_password_email.text.erb +4 -7
- data/app/views/morpho/user_mailer/unlock_token_email.html.erb +4 -6
- data/app/views/morpho/user_mailer/unlock_token_email.text.erb +4 -6
- data/config/locales/morpho.en.yml +60 -0
- data/config/locales/morpho.es.yml +66 -0
- data/lib/generators/morpho/install/templates/app/api/{morphp → morpho}/api.rb +0 -0
- data/lib/generators/morpho/install/templates/config/initializers/morpho.rb +9 -9
- data/lib/morpho/configurations/mailer.rb +4 -0
- data/lib/morpho/engine.rb +24 -5
- data/lib/morpho/validators/contain_number_validator.rb +17 -0
- data/lib/morpho/validators/contain_symbol_validator.rb +17 -0
- data/lib/morpho/validators/contain_uppercase_validator.rb +17 -0
- data/lib/morpho/version.rb +1 -1
- data/lib/morpho.rb +3 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7fca5e64b05dd61217178c941e7f0dece7ad1f5088184e9463b80cd11c16414
|
4
|
+
data.tar.gz: e89d1a456a7b76f24f18bcdde9f5a71a3268258fe2b86f1e868b12cff77a106d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b36cf4a0152b861d01e3e4fe75c0f7c40f31ddfca3209ce07dfcc0f7fed4596d7cf3fc640b3ca188bfdb44de0a0523158b648e7dd074b49b77aa8bb5622cac03
|
7
|
+
data.tar.gz: 91a25b1c00d433111234446830d59eb26a538288519f0f7930434a26e9331178bd579793712683c75d7e94d2aa72320b7d0a961d5c75ff62a698f810503652f5
|
data/README.md
CHANGED
@@ -21,6 +21,45 @@ Or install it yourself as:
|
|
21
21
|
$ gem install morpho
|
22
22
|
```
|
23
23
|
|
24
|
+
## Validators
|
25
|
+
|
26
|
+
### Contain number validator
|
27
|
+
|
28
|
+
Value must contain at least 1 number.
|
29
|
+
|
30
|
+
options:
|
31
|
+
* **message**: A custom message. Defaults to `I18n.t('morpho.labels.validators.contain_number')`
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
class User < ApplicationRecord
|
35
|
+
validates :password, :'morpho/validators/contain_number' => true
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
### Contain uppercase validator
|
40
|
+
Value must contain at least 1 uppercase letter.
|
41
|
+
|
42
|
+
options:
|
43
|
+
* **message**: A custom message. Defaults to `I18n.t('morpho.labels.validators.contain_uppercase')`
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
class User < ApplicationRecord
|
47
|
+
validates :password, :'morpho/validators/contain_uppercase' => true
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
### Contain symbol validator
|
52
|
+
Value must contain at least 1 special char.
|
53
|
+
|
54
|
+
options:
|
55
|
+
* **message**: A custom message. Defaults to `I18n.t('morpho.labels.validators.contain_symbol')`
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
class User < ApplicationRecord
|
59
|
+
validates :password, :'morpho/validators/contain_symbol' => true
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
24
63
|
## Contributing
|
25
64
|
Contribution directions go here.
|
26
65
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Morpho
|
2
2
|
module Entities
|
3
|
-
class AuthenticationToken < ::
|
3
|
+
class AuthenticationToken < ::Morpho::Entities::Base
|
4
4
|
expose :token, documentation: { type: 'string', desc: 'User authentication token', required: true }
|
5
5
|
expose :expires_at, documentation: { type: 'string', desc: 'Authentication token expiration date in millis', required: true }
|
6
6
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Morpho
|
2
2
|
module Entities
|
3
|
-
class UserSignIn < ::
|
3
|
+
class UserSignIn < ::Morpho::Entities::Base
|
4
4
|
expose :email, documentation: { type: 'string', desc: 'User email address' }
|
5
5
|
expose :password, documentation: { type: 'string', desc: 'User password' }
|
6
6
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Morpho
|
2
2
|
module Entities
|
3
|
-
class UserSignUp < ::
|
3
|
+
class UserSignUp < ::Morpho::Entities::Base
|
4
4
|
expose :email, documentation: { type: 'string', desc: 'User email address' }
|
5
5
|
expose :password, documentation: { type: 'string', desc: 'User password' }
|
6
6
|
expose :password_confirmation, documentation: { type: 'string', desc: 'User password confirmation' }
|
@@ -8,10 +8,10 @@ module Morpho
|
|
8
8
|
success Morpho::Entities::User
|
9
9
|
end
|
10
10
|
params do
|
11
|
-
requires :
|
11
|
+
requires :data, type: Morpho::Entities::UserSignUp
|
12
12
|
end
|
13
13
|
post do
|
14
|
-
register(params[:
|
14
|
+
register(params[:data])
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -1,5 +1,17 @@
|
|
1
1
|
module Morpho
|
2
2
|
class ApplicationMailer < ActionMailer::Base
|
3
3
|
layout 'mailer'
|
4
|
+
|
5
|
+
before_action :attach_logo!
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def attach_logo!
|
10
|
+
attachments.inline['logo.png'] = File.read(
|
11
|
+
Rails.root.join('public', 'images', 'mailer-logo.png')
|
12
|
+
)
|
13
|
+
rescue StandardError
|
14
|
+
# do nothing
|
15
|
+
end
|
4
16
|
end
|
5
17
|
end
|
data/app/models/morpho/user.rb
CHANGED
@@ -5,7 +5,10 @@ module Morpho
|
|
5
5
|
has_many :authentications, dependent: :destroy
|
6
6
|
accepts_nested_attributes_for :authentications
|
7
7
|
|
8
|
-
validates :password, length: { minimum: 12 }
|
8
|
+
validates :password, length: { minimum: 12 },
|
9
|
+
:'morpho/validators/contain_number' => true,
|
10
|
+
:'morpho/validators/contain_uppercase' => true,
|
11
|
+
:'morpho/validators/contain_symbol' => true
|
9
12
|
validates :password, confirmation: true
|
10
13
|
validates :email, uniqueness: true
|
11
14
|
validates_email_format_of :email
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
<p>To verify your user email address and activate your user account, just follow this <a href=" <%= @url %>">link</a>.</p>
|
6
|
-
|
7
|
-
<p>Thanks for joining and have a great day!</p>
|
1
|
+
<%= raw(I18n.t('morpho.mailer.activation_needed.body_html',
|
2
|
+
email: @user.email,
|
3
|
+
url: @url
|
4
|
+
)) %>
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
To verify your user email address and activate your user account, just follow this link: <%= @url %>.
|
6
|
-
|
7
|
-
Thanks for joining and have a great day!
|
1
|
+
<%= raw(I18n.t('morpho.mailer.activation_needed.body_text',
|
2
|
+
email: @user.email,
|
3
|
+
url: @url
|
4
|
+
)) %>
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
<p>To login to the site, just follow this link: <%= @url %>.</p>
|
6
|
-
|
7
|
-
<p>Thanks for joining and have a great day!</p>
|
1
|
+
<%= raw(I18n.t('morpho.mailer.activation_success.body_html',
|
2
|
+
email: @user.email,
|
3
|
+
url: @url
|
4
|
+
)) %>
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
To login to the site, just follow this link: <%= @url %>.
|
6
|
-
|
7
|
-
Thanks for joining and have a great day!
|
1
|
+
<%= raw(I18n.t('morpho.mailer.activation_success.body_text',
|
2
|
+
email: @user.email,
|
3
|
+
url: @url
|
4
|
+
)) %>
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
<p>To choose a new password, just follow this <a href=" <%= @url %>">link</a>.</p>
|
6
|
-
|
7
|
-
<p>Have a great day!</p>
|
1
|
+
<%= raw(I18n.t('morpho.mailer.reset_password.body_html',
|
2
|
+
email: @user.email,
|
3
|
+
url: @url
|
4
|
+
)) %>
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
To choose a new password, just follow this link: <%= @url %>.
|
6
|
-
|
7
|
-
Have a great day!
|
1
|
+
<%= raw(I18n.t('morpho.mailer.reset_password.body_text',
|
2
|
+
email: @user.email,
|
3
|
+
url: @url
|
4
|
+
)) %>
|
@@ -1,7 +1,5 @@
|
|
1
|
-
|
1
|
+
<%= raw(I18n.t('morpho.mailer.unlock_token.body_html',
|
2
|
+
email: @user.email,
|
3
|
+
url: @url
|
4
|
+
)) %>
|
2
5
|
|
3
|
-
<p>Your account has been locked due to failed login attempts activity.</p>
|
4
|
-
|
5
|
-
<p>To unlock your account now, just follow this <a href=" <%= @url %>">link</a>. Anyway it will be automatically unlocked in an hour.</p>
|
6
|
-
|
7
|
-
<p>Have a great day!</p>
|
@@ -1,7 +1,5 @@
|
|
1
|
-
|
1
|
+
<%= raw(I18n.t('morpho.mailer.unlock_token.body_text',
|
2
|
+
email: @user.email,
|
3
|
+
url: @url
|
4
|
+
)) %>
|
2
5
|
|
3
|
-
Your account has been locked due to failed login attempts activity.
|
4
|
-
|
5
|
-
To unlock your account now, just follow this link: <%= @url %>. Anyway it will be automatically unlocked in an hour.
|
6
|
-
|
7
|
-
Have a great day!
|
@@ -1,6 +1,10 @@
|
|
1
1
|
en:
|
2
2
|
morpho:
|
3
3
|
labels:
|
4
|
+
validators:
|
5
|
+
contain_symbol: 'must contain a symbol'
|
6
|
+
contain_number: 'must contain a number'
|
7
|
+
contain_uppercase: 'must contain a uppercase letter'
|
4
8
|
sessions:
|
5
9
|
sign_in: 'Sign in'
|
6
10
|
sign_up: 'Sign up with a new user account'
|
@@ -62,12 +66,68 @@ en:
|
|
62
66
|
mailer:
|
63
67
|
activation_needed:
|
64
68
|
subject: 'You have successfully signed up'
|
69
|
+
body_html: |
|
70
|
+
<p>Welcome %{email},</p>
|
71
|
+
<p>You have successfully signed up, you're just a step behind to finish.</p>
|
72
|
+
<p>To verify your user email address and activate your user account, just follow this <a href="%{url}">link</a>.</p>
|
73
|
+
<p>Thanks for joining and have a great day!</p>
|
74
|
+
body_text: |
|
75
|
+
Welcome %{email},
|
76
|
+
|
77
|
+
You have successfully signed up, you're just a step behind to finish.
|
78
|
+
|
79
|
+
To verify your user email address and activate your user account, just follow this link: %{url}.
|
80
|
+
|
81
|
+
Thanks for joining and have a great day!
|
65
82
|
activation_success:
|
66
83
|
subject: 'Your account is now activated'
|
84
|
+
body_html: |
|
85
|
+
<p>Congratulations, %{email}!</p>
|
86
|
+
<p>You have successfully activated your user account.</p>
|
87
|
+
<p>To login to the site, just follow this link: %{url}.</p>
|
88
|
+
<p>Thanks for joining and have a great day!</p>
|
89
|
+
|
90
|
+
body_text: |
|
91
|
+
Congratulations, %{email}!
|
92
|
+
|
93
|
+
You have successfully activated your user account.
|
94
|
+
|
95
|
+
To login to the site, just follow this link: %{url}.
|
96
|
+
|
97
|
+
Thanks for joining and have a great day!
|
98
|
+
|
67
99
|
reset_password:
|
68
100
|
subject: 'You have requested to reset your password'
|
101
|
+
body_html: |
|
102
|
+
<p>Hello %{email},</p>
|
103
|
+
<p>You have requested to reset your password.</p>
|
104
|
+
<p>To choose a new password, just follow this <a href="%{url}">link</a>.</p>
|
105
|
+
<p>Have a great day!</p>
|
106
|
+
body_text: |
|
107
|
+
Hello %{email},
|
108
|
+
|
109
|
+
You have requested to reset your password.
|
110
|
+
|
111
|
+
To choose a new password, just follow this link: %{url}.
|
112
|
+
|
113
|
+
Have a great day!
|
114
|
+
|
69
115
|
unlock_token:
|
70
116
|
subject: 'Your account has been locked'
|
117
|
+
body_html: |
|
118
|
+
<p>Hello %{email},</p>
|
119
|
+
<p>Your account has been locked due to failed login attempts activity.</p>
|
120
|
+
<p>To unlock your account now, just follow this <a href=" %{url}">link</a>. Anyway it will be automatically unlocked in an hour.</p>
|
121
|
+
<p>Have a great day!</p>
|
122
|
+
body_text: |
|
123
|
+
Hello %{email},
|
124
|
+
|
125
|
+
Your account has been locked due to failed login attempts activity.
|
126
|
+
|
127
|
+
To unlock your account now, just follow this link: %{url}. Anyway it will be automatically unlocked in an hour.
|
128
|
+
|
129
|
+
Have a great day!
|
130
|
+
|
71
131
|
api:
|
72
132
|
messages:
|
73
133
|
bad_request: 'Bad request'
|
@@ -0,0 +1,66 @@
|
|
1
|
+
es:
|
2
|
+
morpho:
|
3
|
+
mailer:
|
4
|
+
activation_needed:
|
5
|
+
subject: 'Te has registrado correctamente'
|
6
|
+
body_html: |
|
7
|
+
<p>Bienvenido %{email},</p>
|
8
|
+
<p>Te has registrado exitosamente, solo estás un paso atrás para terminar.</p>
|
9
|
+
<p>Para verificar su dirección de correo electrónico de usuario y activar su cuenta de usuario, simplemente siga este <a href="%{url}">enlace</a>.</p>
|
10
|
+
<p>Gracias por unirte y que tengas un gran día!</p>
|
11
|
+
body_text: |
|
12
|
+
Bienvenido %{email},
|
13
|
+
|
14
|
+
Te has registrado exitosamente, solo estás un paso atrás para terminar.
|
15
|
+
|
16
|
+
Para verificar su dirección de correo electrónico de usuario y activar su cuenta de usuario, simplemente siga este enlace: %{url}.
|
17
|
+
|
18
|
+
Gracias por unirte y que tengas un gran día!
|
19
|
+
activation_success:
|
20
|
+
subject: 'Tu cuenta ya está activada'
|
21
|
+
body_html: |
|
22
|
+
<p>Felicidades, %{email}!</p>
|
23
|
+
<p>Has activado exitosamente tu cuenta de usuario.</p>
|
24
|
+
<p>Para iniciar sesión en el sitio, simplemente siga este enlace: %{url}.</p>
|
25
|
+
<p>Gracias por unirte y que tengas un gran día!</p>
|
26
|
+
|
27
|
+
body_text: |
|
28
|
+
Felicidades, %{email}!
|
29
|
+
|
30
|
+
Has activado exitosamente tu cuenta de usuario.
|
31
|
+
|
32
|
+
Para iniciar sesión en el sitio, simplemente siga este enlace: %{url}.
|
33
|
+
|
34
|
+
Gracias por unirte y que tengas un gran día!
|
35
|
+
|
36
|
+
reset_password:
|
37
|
+
subject: 'Has solicitado restablecer tu contraseña'
|
38
|
+
body_html: |
|
39
|
+
<p>Hola %{email},</p>
|
40
|
+
<p>Has solicitado restablecer tu contraseña.</p>
|
41
|
+
<p>Para elegir una nueva contraseña, simplemente siga este <a href="%{url}">enlace</a>.</p>
|
42
|
+
<p>¡Que tengas un gran día!</p>
|
43
|
+
body_text: |
|
44
|
+
Hola %{email},
|
45
|
+
|
46
|
+
Has solicitado restablecer tu contraseña.
|
47
|
+
|
48
|
+
Para elegir una nueva contraseña, simplemente siga este: %{url}.
|
49
|
+
|
50
|
+
¡Que tengas un gran día!
|
51
|
+
|
52
|
+
unlock_token:
|
53
|
+
subject: 'Su cuenta ha sido bloqueada'
|
54
|
+
body_html: |
|
55
|
+
<p>Hola %{email},</p>
|
56
|
+
<p>Su cuenta ha sido bloqueada debido a una actividad fallida de intentos de inicio de sesión.</p>
|
57
|
+
<p>Para desbloquear tu cuenta ahora, solo sigue este <a href=" %{url}">enlace</a>. De todos modos se desbloqueará automáticamente en una hora.</p>
|
58
|
+
<p>¡Que tengas un gran día!</p>
|
59
|
+
body_text: |
|
60
|
+
Hola %{email},
|
61
|
+
|
62
|
+
Su cuenta ha sido bloqueada debido a una actividad fallida de intentos de inicio de sesión.
|
63
|
+
|
64
|
+
Para desbloquear tu cuenta ahora, solo sigue este enlace: %{url}. De todos modos se desbloqueará automáticamente en una hora.
|
65
|
+
|
66
|
+
¡Que tengas un gran día!
|
File without changes
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Morpho.configure do |config|
|
2
|
-
config.host = 'localhost:3000'
|
3
|
-
config.mailer.from = ''
|
4
|
-
config.mailer.address = 'smtp.mailtrap.io'
|
5
|
-
config.mailer.user_name = ''
|
6
|
-
config.mailer.password = ''
|
7
|
-
config.mailer.port = 2525
|
8
|
-
config.mailer.authentication = '
|
9
|
-
config.mailer.enable_starttls_auto = false
|
2
|
+
config.host = ENV.fetch('HOST', 'localhost:3000')
|
3
|
+
config.mailer.from = ENV.fetch('MAILER_FROM', 'no-reply@example.com')
|
4
|
+
config.mailer.address = ENV.fetch('MAILER_ADDRESS', 'smtp.mailtrap.io')
|
5
|
+
config.mailer.user_name = ENV.fetch('MAILER_USER_NAME', '')
|
6
|
+
config.mailer.password = ENV.fetch('MAILER_PASSWORD', '')
|
7
|
+
config.mailer.port = ENV.fetch('MAILER_PORT', 2525)
|
8
|
+
config.mailer.authentication = ENV.fetch('MAILER_AUTHENTICATION').to_s.to_sym
|
9
|
+
config.mailer.enable_starttls_auto = ENV.fetch('MAILER_ENABLE_STARTTLS_AUTO', false)
|
10
10
|
config.jwt.secret = ''
|
11
11
|
config.jwt.algorithm = 'HS256'
|
12
12
|
config.jwt.header = 'Authorization'
|
@@ -14,4 +14,4 @@ Morpho.configure do |config|
|
|
14
14
|
config.api.title = ''
|
15
15
|
config.api.description = ''
|
16
16
|
config.auth.failed_login_attempts_limit = 5
|
17
|
-
end
|
17
|
+
end
|
@@ -8,8 +8,12 @@ module Morpho
|
|
8
8
|
attr_accessor :port
|
9
9
|
attr_accessor :authentication
|
10
10
|
attr_accessor :enable_starttls_auto
|
11
|
+
attr_accessor :perform_deliveries
|
12
|
+
attr_accessor :delivery_method
|
11
13
|
|
12
14
|
def initialize
|
15
|
+
self.perform_deliveries = true
|
16
|
+
self.delivery_method = :smtp
|
13
17
|
self.from = ''
|
14
18
|
self.address = ''
|
15
19
|
self.user_name = ''
|
data/lib/morpho/engine.rb
CHANGED
@@ -14,18 +14,21 @@ module Morpho
|
|
14
14
|
end
|
15
15
|
|
16
16
|
initializer 'morpho.configurations', after: :load_config_initializers do |app|
|
17
|
-
ActionMailer::Base
|
18
|
-
|
17
|
+
mailer = ActionMailer::Base
|
18
|
+
mailer.delivery_method = Morpho.config.mailer.delivery_method
|
19
|
+
.to_s.to_sym
|
20
|
+
mailer.perform_deliveries = Morpho.config.mailer
|
21
|
+
.perform_deliveries
|
19
22
|
|
20
|
-
|
23
|
+
mailer.default_options = {
|
21
24
|
from: Morpho.config.mailer.from
|
22
25
|
}
|
23
26
|
|
24
|
-
|
27
|
+
mailer.default_url_options = {
|
25
28
|
host: Morpho.config.host
|
26
29
|
}
|
27
30
|
|
28
|
-
|
31
|
+
mailer.smtp_settings = {
|
29
32
|
address: Morpho.config.mailer.address,
|
30
33
|
port: Morpho.config.mailer.port,
|
31
34
|
user_name: Morpho.config.mailer.user_name,
|
@@ -34,5 +37,21 @@ module Morpho
|
|
34
37
|
enable_starttls_auto: Morpho.config.mailer.enable_starttls_auto
|
35
38
|
}
|
36
39
|
end
|
40
|
+
|
41
|
+
def self.controllers_path
|
42
|
+
Pathname.new(
|
43
|
+
Morpho::Engine.root.join(
|
44
|
+
'app', 'controllers', 'morpho'
|
45
|
+
)
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.models_path
|
50
|
+
Pathname.new(
|
51
|
+
Morpho::Engine.root.join(
|
52
|
+
'app', 'models', 'morpho'
|
53
|
+
)
|
54
|
+
)
|
55
|
+
end
|
37
56
|
end
|
38
57
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Morpho
|
2
|
+
module Validators
|
3
|
+
class ContainNumberValidator < ActiveModel::EachValidator
|
4
|
+
NUMBER_FORMAT = /\A(?=.*\d)/x
|
5
|
+
|
6
|
+
def validate_each(record, attribute, value)
|
7
|
+
unless value =~ self.class::NUMBER_FORMAT
|
8
|
+
record.errors.add(
|
9
|
+
attribute,
|
10
|
+
options[:message] ||
|
11
|
+
I18n.t('morpho.labels.validators.contain_number')
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Morpho
|
2
|
+
module Validators
|
3
|
+
class ContainSymbolValidator < ActiveModel::EachValidator
|
4
|
+
SYMBOL_FORMAT = /\A(?=.*[[:^alnum:]])/x
|
5
|
+
|
6
|
+
def validate_each(record, attribute, value)
|
7
|
+
unless value =~ self.class::SYMBOL_FORMAT
|
8
|
+
record.errors.add(
|
9
|
+
attribute,
|
10
|
+
options[:message] ||
|
11
|
+
I18n.t('morpho.labels.validators.contain_symbol')
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Morpho
|
2
|
+
module Validators
|
3
|
+
class ContainUppercaseValidator < ActiveModel::EachValidator
|
4
|
+
UPPERCASE_FORMAT = /\A(?=.*[A-Z])/x
|
5
|
+
|
6
|
+
def validate_each(record, attribute, value)
|
7
|
+
unless value =~ self.class::UPPERCASE_FORMAT
|
8
|
+
record.errors.add(
|
9
|
+
attribute,
|
10
|
+
options[:message] ||
|
11
|
+
I18n.t('morpho.labels.validators.contain_uppercase')
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/morpho/version.rb
CHANGED
data/lib/morpho.rb
CHANGED
@@ -2,6 +2,9 @@ require 'morpho/loader'
|
|
2
2
|
require 'morpho/engine'
|
3
3
|
require 'morpho/version'
|
4
4
|
require 'morpho/configuration'
|
5
|
+
require 'morpho/validators/contain_number_validator'
|
6
|
+
require 'morpho/validators/contain_uppercase_validator'
|
7
|
+
require 'morpho/validators/contain_symbol_validator'
|
5
8
|
|
6
9
|
module Morpho
|
7
10
|
class << self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morpho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hugo Gilmar Erazo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -237,6 +237,7 @@ files:
|
|
237
237
|
- app/api/concerns/morpho/grape/user_registration.rb
|
238
238
|
- app/api/concerns/morpho/grape/user_unlock.rb
|
239
239
|
- app/api/morpho/entities/authentication_token.rb
|
240
|
+
- app/api/morpho/entities/base.rb
|
240
241
|
- app/api/morpho/entities/user.rb
|
241
242
|
- app/api/morpho/entities/user_sign_in.rb
|
242
243
|
- app/api/morpho/entities/user_sign_up.rb
|
@@ -286,6 +287,7 @@ files:
|
|
286
287
|
- config/initializers/simple_form.rb
|
287
288
|
- config/initializers/sorcery.rb
|
288
289
|
- config/locales/morpho.en.yml
|
290
|
+
- config/locales/morpho.es.yml
|
289
291
|
- config/routes.rb
|
290
292
|
- db/migrate/20180919162009_sorcery_core.rb
|
291
293
|
- db/migrate/20180919162055_sorcery_remember_me.rb
|
@@ -295,7 +297,7 @@ files:
|
|
295
297
|
- db/migrate/20180919162059_sorcery_activity_logging.rb
|
296
298
|
- db/migrate/20180919162100_sorcery_external.rb
|
297
299
|
- lib/generators/morpho/install/install_generator.rb
|
298
|
-
- lib/generators/morpho/install/templates/app/api/
|
300
|
+
- lib/generators/morpho/install/templates/app/api/morpho/api.rb
|
299
301
|
- lib/generators/morpho/install/templates/config/initializers/morpho.rb
|
300
302
|
- lib/generators/morpho/install/templates/public/favicon-16x16.png
|
301
303
|
- lib/generators/morpho/install/templates/public/favicon-32x32.png
|
@@ -308,6 +310,9 @@ files:
|
|
308
310
|
- lib/morpho/configurations/mailer.rb
|
309
311
|
- lib/morpho/engine.rb
|
310
312
|
- lib/morpho/loader.rb
|
313
|
+
- lib/morpho/validators/contain_number_validator.rb
|
314
|
+
- lib/morpho/validators/contain_symbol_validator.rb
|
315
|
+
- lib/morpho/validators/contain_uppercase_validator.rb
|
311
316
|
- lib/morpho/version.rb
|
312
317
|
- lib/tasks/morpho_tasks.rake
|
313
318
|
- lib/templates/erb/scaffold/_form.html.erb
|