morpho 0.2.1 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7fca5e64b05dd61217178c941e7f0dece7ad1f5088184e9463b80cd11c16414
4
- data.tar.gz: e89d1a456a7b76f24f18bcdde9f5a71a3268258fe2b86f1e868b12cff77a106d
3
+ metadata.gz: c0338ac8728b7b68d4573d522582176ef24120d8ee32b166a4b47a4cc2c31a80
4
+ data.tar.gz: f1b00da0632ea3ec3f63c60cbdb01b378b404fdbb6c24696c10cfea8291a29d4
5
5
  SHA512:
6
- metadata.gz: b36cf4a0152b861d01e3e4fe75c0f7c40f31ddfca3209ce07dfcc0f7fed4596d7cf3fc640b3ca188bfdb44de0a0523158b648e7dd074b49b77aa8bb5622cac03
7
- data.tar.gz: 91a25b1c00d433111234446830d59eb26a538288519f0f7930434a26e9331178bd579793712683c75d7e94d2aa72320b7d0a961d5c75ff62a698f810503652f5
6
+ metadata.gz: 11778c465a75f168c1a1a8db55ca70d3b9d70b8f61d0dd69743fcfccfc3e7c3951d9d29c287587ad7ee2e1cadb1d3059f990a0dd51f709e63c060feb9813abd4
7
+ data.tar.gz: 1674597483b4ea9c1098dd92936796a394c790a2403e9702ae3225949862109cf8d54411540411fb3a0753940ace36a724dd1ce30a02080506f3a797705661ce
@@ -55,12 +55,12 @@ module Morpho
55
55
  end
56
56
 
57
57
  def jwt_encode(payload)
58
- JWT.encode(payload, Morpho.config.jwt.secret, Morpho.config.jwt.algorithm)
58
+ Morpho::Cipher.jwt_encode(payload)
59
59
  end
60
60
 
61
61
  def jwt_decode(token)
62
62
  begin
63
- return JWT.decode(token, Morpho.config.jwt.secret, true, { algorithm: Morpho.config.jwt.algorithm })
63
+ return Morpho::Cipher.jwt_decode(token)
64
64
  rescue
65
65
  nil
66
66
  end
@@ -0,0 +1,8 @@
1
+ module Morpho
2
+ module Entities
3
+ class Error < ::Grape::Entity
4
+ expose :message, documentation: { type: 'string', desc: 'Error standard message', required: true }
5
+ expose :errors, safe: true, documentation: { type: 'string', desc: 'Error message details', is_array: true }
6
+ end
7
+ end
8
+ end
@@ -12,77 +12,4 @@
12
12
  *
13
13
  *= require_self
14
14
  */
15
- @import 'https://fonts.googleapis.com/css?family=Raleway:400,300,600';
16
- @import 'https://cdn.jsdelivr.net/npm/skeleton-css@2.0.4/css/normalize.css';
17
- @import 'https://cdn.jsdelivr.net/npm/skeleton-css@2.0.4/css/skeleton.css';
18
-
19
- body {
20
- padding: 2em 1em;
21
- }
22
-
23
- .alert {
24
- display: block;
25
- padding: 1em;
26
- border-left: 5px solid;
27
- margin-bottom: 1em;
28
- }
29
-
30
- .alert-success {
31
- background-color: #D5F5E3;
32
- border-left-color: #2ECC71;
33
- color: #2ECC71;
34
- }
35
-
36
- .alert-info {
37
- background-color: #D6EAF8;
38
- border-left-color: #3498DB;
39
- color: #3498DB;
40
- }
41
-
42
- .alert-warning {
43
- background-color: #FCF3CF;
44
- border-left-color: #F1C40F;
45
- color: #F1C40F;
46
- }
47
-
48
- .alert-error {
49
- background-color: #F2D7D5;
50
- border-left-color: #C0392B;
51
- color: #C0392B;
52
- }
53
-
54
- .field_with_errors {
55
- padding-bottom: 1em;
56
- }
57
-
58
- .field_with_errors input, .field_with_errors textarea, .field_with_errors select {
59
- margin-bottom: 0.5em;
60
- }
61
-
62
- .field_with_errors span.error {
63
- color: #C0392B;
64
- text-transform: lowercase;
65
- }
66
-
67
- .input label.boolean {
68
- display: inline;
69
- font-weight: normal;
70
- margin-left: 0.5em;
71
- }
72
-
73
- ul.unstyled {
74
- list-style: none;
75
- }
76
-
77
- .sign-in-form, .sign-up-form, .activation-form, .reset-password-form, .unlock-form {
78
- position: relative;
79
- height: 50vh;
80
- }
81
-
82
- .sign-in-form form, .sign-up-form form, .activation-form form, .reset-password-form form, .unlock-form form {
83
- position: absolute;
84
- top: 50%;
85
- left: 50%;
86
- transform: translate(-50%, -50%);
87
- width: 50vh;
88
- }
15
+ @import 'https://fonts.googleapis.com/css?family=Raleway:400,300,600';
@@ -17,9 +17,9 @@ module Morpho
17
17
  def show
18
18
  if user && !user.active?
19
19
  user.activate!
20
- redirect_to sign_in_path, success: I18n.t('morpho.messages.activations.activate.success')
20
+ render "morpho/activations/success"
21
21
  else
22
- redirect_to sign_in_path, error: I18n.t('morpho.messages.activations.activate.failure')
22
+ render "morpho/activations/failure"
23
23
  end
24
24
  end
25
25
 
@@ -5,7 +5,7 @@ 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: Morpho.config.auth.password_minimum_length },
9
9
  :'morpho/validators/contain_number' => true,
10
10
  :'morpho/validators/contain_uppercase' => true,
11
11
  :'morpho/validators/contain_symbol' => true
@@ -0,0 +1,17 @@
1
+ <div class="tw-flex tw-flex-wrap tw-h-screen tw-items-center tw-content-center tw-text-grey-dark tw-text-4xl">
2
+ <div class="tw-w-full lg:tw-w-3/4 tw-mx-auto tw-text-center">
3
+ <h3 class="tw-text-5xl tw-pb-16 tw-text-grey-dark">
4
+ Token inválido
5
+ </h3>
6
+ <div class="">
7
+
8
+ </div>
9
+
10
+ <div class="tw-pt-24 tw-px-32 ">
11
+ <p>
12
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
13
+ </p>
14
+ </div>
15
+
16
+ </div>
17
+ </div>
@@ -1,10 +1,10 @@
1
- <div class="activation-form">
1
+ <div class="">
2
2
  <%= simple_form_for :user, url: send_activation_path do |f| %>
3
- <%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: 'u-full-width' } %>
3
+ <%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: '' } %>
4
4
 
5
- <%= f.submit t('morpho.labels.activations.send_instructions'), class: 'button-primary u-full-width' %>
5
+ <%= f.submit t('morpho.labels.activations.send_instructions'), class: '' %>
6
6
 
7
- <ul class="unstyled">
7
+ <ul class="">
8
8
  <li>
9
9
  <%= link_to t('morpho.labels.activations.sign_in'), sign_in_path %>
10
10
  </li>
@@ -0,0 +1,17 @@
1
+ <div class="">
2
+ <div class="">
3
+ <h3 class="">
4
+ Cuenta activada
5
+ </h3>
6
+ <div class="">
7
+ <%= link_to 'Iniciar sesión', sign_in_path , class: "" %>
8
+ </div>
9
+
10
+ <div class="">
11
+ <p>
12
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
13
+ </p>
14
+ </div>
15
+
16
+ </div>
17
+ </div>
@@ -1,12 +1,12 @@
1
- <div class="sign-up-form">
1
+ <div class="">
2
2
  <%= simple_form_for user, url: change_password_path(token: params[:token]), method: :put do |f| %>
3
- <%= f.input :password, required: true, placeholder: '************', input_html: { class: 'u-full-width' } %>
3
+ <%= f.input :password, required: true, placeholder: '************', input_html: { class: '' } %>
4
4
 
5
- <%= f.input :password_confirmation, required: true, placeholder: '************', input_html: { class: 'u-full-width' } %>
5
+ <%= f.input :password_confirmation, required: true, placeholder: '************', input_html: { class: '' } %>
6
6
 
7
- <%= f.submit t('morpho.labels.passwords.change_password'), class: 'button-primary u-full-width' %>
7
+ <%= f.submit t('morpho.labels.passwords.change_password'), class: '' %>
8
8
 
9
- <ul class="unstyled">
9
+ <ul class="">
10
10
  <li>
11
11
  <%= link_to t('morpho.labels.passwords.sign_in'), sign_in_path %>
12
12
  </li>
@@ -1,10 +1,10 @@
1
- <div class="reset-password-form">
1
+ <div class="">
2
2
  <%= simple_form_for :user, url: send_reset_password_path do |f| %>
3
- <%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: 'u-full-width' } %>
3
+ <%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: '' } %>
4
4
 
5
- <%= f.submit t('morpho.labels.passwords.send_instructions'), class: 'button-primary u-full-width' %>
5
+ <%= f.submit t('morpho.labels.passwords.send_instructions'), class: 'button-primary ' %>
6
6
 
7
- <ul class="unstyled">
7
+ <ul class="">
8
8
  <li>
9
9
  <%= link_to t('morpho.labels.passwords.sign_in'), sign_in_path %>
10
10
  </li>
@@ -1,14 +1,14 @@
1
- <div class="sign-in-form">
1
+ <div class="">
2
2
  <%= simple_form_for :session, url: sign_in_path do |f| %>
3
- <%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: 'u-full-width' } %>
3
+ <%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: '' } %>
4
4
 
5
- <%= f.input :password, required: true, placeholder: '************', input_html: { class: 'u-full-width' } %>
5
+ <%= f.input :password, required: true, placeholder: '************', input_html: { class: '' } %>
6
6
 
7
7
  <%= f.input :remember_me, as: :boolean %>
8
8
 
9
- <%= f.submit t('morpho.labels.sessions.sign_in'), class: 'button-primary u-full-width' %>
9
+ <%= f.submit t('morpho.labels.sessions.sign_in'), class: '' %>
10
10
 
11
- <ul class="unstyled">
11
+ <ul class="">
12
12
  <li>
13
13
  <%= link_to t('morpho.labels.sessions.sign_up'), sign_up_path %>
14
14
  </li>
@@ -1,10 +1,10 @@
1
- <div class="unlock-form">
1
+ <div class="">
2
2
  <%= simple_form_for :user, url: send_unlock_path do |f| %>
3
- <%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: 'u-full-width' } %>
3
+ <%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: '' } %>
4
4
 
5
- <%= f.submit t('morpho.labels.unlocks.send_instructions'), class: 'button-primary u-full-width' %>
5
+ <%= f.submit t('morpho.labels.unlocks.send_instructions'), class: '' %>
6
6
 
7
- <ul class="unstyled">
7
+ <ul class="">
8
8
  <li>
9
9
  <%= link_to t('morpho.labels.unlocks.sign_in'), sign_in_path %>
10
10
  </li>
@@ -1,14 +1,14 @@
1
- <div class="sign-up-form">
1
+ <div class="">
2
2
  <%= simple_form_for user, url: sign_up_path do |f| %>
3
- <%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: 'u-full-width' } %>
3
+ <%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: '' } %>
4
4
 
5
- <%= f.input :password, required: true, placeholder: '************', input_html: { class: 'u-full-width' } %>
5
+ <%= f.input :password, required: true, placeholder: '************', input_html: { class: '' } %>
6
6
 
7
- <%= f.input :password_confirmation, required: true, placeholder: '************', input_html: { class: 'u-full-width' } %>
7
+ <%= f.input :password_confirmation, required: true, placeholder: '************', input_html: { class: '' } %>
8
8
 
9
- <%= f.submit t('morpho.labels.users.sign_up'), class: 'button-primary u-full-width' %>
9
+ <%= f.submit t('morpho.labels.users.sign_up'), class: '' %>
10
10
 
11
- <ul class="unstyled">
11
+ <ul class="">
12
12
  <li>
13
13
  <%= link_to t('morpho.labels.users.sign_in'), sign_in_path %>
14
14
  </li>
@@ -1,5 +1,68 @@
1
1
  es:
2
2
  morpho:
3
+ labels:
4
+ validators:
5
+ contain_symbol: 'debe de contener un caracter especial'
6
+ contain_number: 'debe de contener un número'
7
+ contain_uppercase: 'debe de contener al menos una letra en mayúscula'
8
+ sessions:
9
+ sign_in: 'Iniciar sesión'
10
+ sign_up: 'Regístrate con una nueva cuenta de usuario'
11
+ password_reset: 'Restablecer la contraseña de mi cuenta'
12
+ unlock: 'Desbloquear mi cuenta'
13
+ users:
14
+ sign_up: 'Regístrate'
15
+ sign_in: 'Inicia sesión con una cuenta de usuario existente'
16
+ activation: 'Activar mi cuenta'
17
+ passwords:
18
+ send_instructions: 'Enviar instrucciones de restablecer contraseña'
19
+ sign_in: 'Inicia sesión con una cuenta de usuario existente'
20
+ sign_up: 'Regístrate con una nueva cuenta de usuario'
21
+ change_password: 'Cambiar mi contraseña'
22
+ activations:
23
+ send_instructions: 'Enviar instrucciones de activación'
24
+ sign_in: 'Inicia sesión con una cuenta de usuario existente'
25
+ sign_up: 'Regístrate con una nueva cuenta de usuario'
26
+ unlocks:
27
+ send_instructions: 'Enviar instrucciones de desbloqueo'
28
+ sign_in: 'Inicia sesión con una cuenta de usuario existente'
29
+ sign_up: 'Regístrate con una nueva cuenta de usuario'
30
+ messages:
31
+ unauthenticated: 'Necesitas iniciar sesión primero'
32
+ sessions:
33
+ create:
34
+ success: 'Inicia sesión exitosamente'
35
+ failure: 'Error de inicio de sesión, por favor verifique la información proporcionada'
36
+ destroy:
37
+ success: 'Usted cierra la sesión con éxito'
38
+ users:
39
+ create:
40
+ success: 'Regístrese con éxito, recibirá un correo electrónico con instrucciones de activación de cuenta.'
41
+ failure: 'Registro fallido, por favor revise los errores a continuación'
42
+ passwords:
43
+ create:
44
+ success: 'Recibirá instrucciones para restablecer su contraseña en su buzón de correo electrónico.'
45
+ failure: 'No se ha encontrado ninguna cuenta de usuario con ese correo electrónico.'
46
+ edit:
47
+ success: 'Ingrese su nueva contraseña en los campos de abajo'
48
+ failure: 'Error al restablecer la contraseña, solicitar un nuevo token de activación'
49
+ update:
50
+ success: 'Contraseña modificada correctamente, inicie sesión para continuar'
51
+ failure: 'Error de cambio de contraseña, por favor revise los errores a continuación'
52
+ activations:
53
+ create:
54
+ success: 'Recibirá instrucciones de activación de cuenta de usuario en su buzón de correo electrónico.'
55
+ failure: 'Ninguna cuenta de usuario encontrada con ese correo electrónico o cuenta de usuario ya está activa'
56
+ activate:
57
+ success: 'Activación exitosa, inicie sesión para continuar'
58
+ failure: 'La activación falló, solicita un nuevo token de activación'
59
+ unlocks:
60
+ create:
61
+ success: 'Recibirás instrucciones de desbloqueo de cuenta de usuario en tu buzón de correo electrónico.'
62
+ failure: 'Ninguna cuenta de usuario encontrada con ese correo electrónico o cuenta de usuario ya está desbloqueada'
63
+ unlock:
64
+ success: 'Desbloqueo exitoso, inicia sesión para continuar'
65
+ failure: 'Falló el desbloqueo, solicita un nuevo token de desbloqueo'
3
66
  mailer:
4
67
  activation_needed:
5
68
  subject: 'Te has registrado correctamente'
@@ -63,4 +126,28 @@ es:
63
126
 
64
127
  Para desbloquear tu cuenta ahora, solo sigue este enlace: %{url}. De todos modos se desbloqueará automáticamente en una hora.
65
128
 
66
- ¡Que tengas un gran día!
129
+ ¡Que tengas un gran día!
130
+
131
+ api:
132
+ messages:
133
+ bad_request: 'Solicitud incorrecta'
134
+ unauthorized: 'No autorizado'
135
+ payment_required: 'Pago requerido'
136
+ forbidden: 'Prohibido'
137
+ not_found: 'No encontrado'
138
+ method_not_allowed: 'Método no permitido'
139
+ unprocessable_entity: 'Entidad no procesable'
140
+ simple_form:
141
+ 'yes': 'Si'
142
+ 'no': 'No'
143
+ required:
144
+ text: 'requerido'
145
+ mark: '*'
146
+ error_notification:
147
+ default_message: 'Por favor revise los problemas a continuación:'
148
+ labels:
149
+ defaults:
150
+ email: 'Correo electrónico'
151
+ password: 'Contraseña'
152
+ password_confirmation: 'Confirmar la contraseña'
153
+ remember_me: 'Recuérdame'
data/lib/morpho.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'morpho/loader'
2
2
  require 'morpho/engine'
3
+ require 'morpho/cipher'
3
4
  require 'morpho/version'
4
5
  require 'morpho/configuration'
5
6
  require 'morpho/validators/contain_number_validator'
@@ -0,0 +1,13 @@
1
+ module Morpho
2
+ module Cipher
3
+ module_function
4
+
5
+ def jwt_encode(payload, algorithm = Morpho.config.jwt.algorithm)
6
+ JWT.encode(payload, Morpho.config.jwt.secret, algorithm)
7
+ end
8
+
9
+ def jwt_decode(token, algorithm = Morpho.config.jwt.algorithm)
10
+ JWT.decode(token, Morpho.config.jwt.secret, true, algorithm: algorithm)
11
+ end
12
+ end
13
+ end
@@ -2,9 +2,10 @@ module Morpho
2
2
  module Configurations
3
3
  class Auth
4
4
  attr_accessor :failed_login_attempts_limit
5
-
5
+ attr_accessor :password_minimum_length
6
6
  def initialize
7
7
  self.failed_login_attempts_limit = 0
8
+ self.password_minimum_length = 8
8
9
  end
9
10
  end
10
11
  end
data/lib/morpho/loader.rb CHANGED
@@ -9,3 +9,4 @@ require 'grape-entity'
9
9
  require 'grape-swagger'
10
10
  require 'grape-swagger/entity'
11
11
  require 'grape-swagger/representable'
12
+ require 'rails-i18n'
@@ -1,3 +1,3 @@
1
1
  module Morpho
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
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.1
4
+ version: 0.3.0
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-17 00:00:00.000000000 Z
11
+ date: 2018-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: 0.2.2
181
+ - !ruby/object:Gem::Dependency
182
+ name: rails-i18n
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '5.1'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '5.1'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: sqlite3
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -238,6 +252,7 @@ files:
238
252
  - app/api/concerns/morpho/grape/user_unlock.rb
239
253
  - app/api/morpho/entities/authentication_token.rb
240
254
  - app/api/morpho/entities/base.rb
255
+ - app/api/morpho/entities/error.rb
241
256
  - app/api/morpho/entities/user.rb
242
257
  - app/api/morpho/entities/user_sign_in.rb
243
258
  - app/api/morpho/entities/user_sign_up.rb
@@ -268,7 +283,9 @@ files:
268
283
  - app/views/layouts/morpho/application.html.erb
269
284
  - app/views/layouts/morpho/mailer.html.erb
270
285
  - app/views/layouts/morpho/mailer.text.erb
286
+ - app/views/morpho/activations/failure.html.erb
271
287
  - app/views/morpho/activations/new.html.erb
288
+ - app/views/morpho/activations/success.html.erb
272
289
  - app/views/morpho/home/index.html.erb
273
290
  - app/views/morpho/passwords/edit.html.erb
274
291
  - app/views/morpho/passwords/new.html.erb
@@ -303,6 +320,7 @@ files:
303
320
  - lib/generators/morpho/install/templates/public/favicon-32x32.png
304
321
  - lib/generators/morpho/install/templates/public/favicon.ico
305
322
  - lib/morpho.rb
323
+ - lib/morpho/cipher.rb
306
324
  - lib/morpho/configuration.rb
307
325
  - lib/morpho/configurations/api.rb
308
326
  - lib/morpho/configurations/auth.rb