lockify 0.1.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +87 -0
- data/Rakefile +8 -0
- data/app/controllers/users/confirmations_controller.rb +62 -0
- data/app/controllers/users/passwords_controller.rb +62 -0
- data/app/controllers/users/registrations_controller.rb +126 -0
- data/app/controllers/users/sessions_controller.rb +68 -0
- data/app/mailers/user_mailer.rb +21 -0
- data/app/models/concerns/lockify_user.rb +138 -0
- data/app/views/lockify/confirmations/new.html.erb +16 -0
- data/app/views/lockify/passwords/edit.html.erb +25 -0
- data/app/views/lockify/passwords/new.html.erb +16 -0
- data/app/views/lockify/registrations/new.html.erb +29 -0
- data/app/views/lockify/sessions/new.html.erb +26 -0
- data/app/views/lockify/shared/_error_messages.html.erb +15 -0
- data/app/views/lockify/shared/_links.html.erb +19 -0
- data/config/locales/en.yml +55 -0
- data/config/locales/es.yml +55 -0
- data/config/routes.rb +28 -0
- data/lib/generators/lockify/install/install_generator.rb +95 -0
- data/lib/generators/lockify/install/templates/README +37 -0
- data/lib/generators/lockify/install/templates/migration.rb +38 -0
- data/lib/generators/lockify/views/views_generator.rb +13 -0
- data/lib/lockify/controllers/helpers.rb +76 -0
- data/lib/lockify/engine.rb +44 -0
- data/lib/lockify/version.rb +3 -0
- data/lib/lockify.rb +33 -0
- metadata +109 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<h2><%= t('.sign_in') %></h2>
|
2
|
+
|
3
|
+
<%= form_with(model: resource, as: :user, url: user_session_path, local: true) do |f| %>
|
4
|
+
<div class="field">
|
5
|
+
<%= f.label :email %>
|
6
|
+
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="field">
|
10
|
+
<%= f.label :password %>
|
11
|
+
<%= f.password_field :password, autocomplete: "current-password" %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<% if devise_mapping.rememberable? %>
|
15
|
+
<div class="field">
|
16
|
+
<%= f.check_box :remember_me %>
|
17
|
+
<%= f.label :remember_me %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<div class="actions">
|
22
|
+
<%= f.submit t('.sign_in') %>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<%= render "lockify/shared/links" %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if resource.errors.any? %>
|
2
|
+
<div id="error_explanation" data-turbo-cache="false">
|
3
|
+
<h2>
|
4
|
+
<%= I18n.t("errors.messages.not_saved",
|
5
|
+
count: resource.errors.count,
|
6
|
+
resource: resource.class.model_name.human.downcase)
|
7
|
+
%>
|
8
|
+
</h2>
|
9
|
+
<ul>
|
10
|
+
<% resource.errors.full_messages.each do |message| %>
|
11
|
+
<li><%= message %></li>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%- if controller_name != 'sessions' %>
|
2
|
+
<%= link_to t('.sign_in'), new_user_session_path %><br />
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
6
|
+
<%= link_to t('.sign_up'), new_user_registration_path %><br />
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
10
|
+
<%= link_to t('.forgot_your_password'), new_user_password_path %><br />
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
14
|
+
<%= link_to t('.didn_t_receive_confirmation_instructions'), new_user_confirmation_path %><br />
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
18
|
+
<%= link_to t('.didn_t_receive_unlock_instructions'), new_user_unlock_path %><br />
|
19
|
+
<% end %>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
en:
|
2
|
+
lockify:
|
3
|
+
sessions:
|
4
|
+
signed_in: "Signed in successfully."
|
5
|
+
signed_out: "Signed out successfully."
|
6
|
+
invalid: "Invalid Email or password."
|
7
|
+
unconfirmed: "You have to confirm your email address before continuing."
|
8
|
+
locked: "Your account is locked."
|
9
|
+
new:
|
10
|
+
sign_in: "Log in"
|
11
|
+
|
12
|
+
registrations:
|
13
|
+
signed_up: "Welcome! You have signed up successfully."
|
14
|
+
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
|
15
|
+
updated: "Your account has been updated successfully."
|
16
|
+
destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
|
17
|
+
new:
|
18
|
+
sign_up: "Sign up"
|
19
|
+
|
20
|
+
passwords:
|
21
|
+
send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
|
22
|
+
updated: "Your password has been changed successfully. You are now signed in."
|
23
|
+
expired: "Your password reset token has expired. Please request a new one."
|
24
|
+
new:
|
25
|
+
forgot_your_password: "Forgot your password?"
|
26
|
+
send_me_reset_password_instructions: "Send me reset password instructions"
|
27
|
+
edit:
|
28
|
+
change_your_password: "Change your password"
|
29
|
+
new_password: "New password"
|
30
|
+
confirm_new_password: "Confirm new password"
|
31
|
+
change_my_password: "Change my password"
|
32
|
+
|
33
|
+
confirmations:
|
34
|
+
confirmed: "Your email address has been successfully confirmed."
|
35
|
+
send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
|
36
|
+
already_confirmed: "was already confirmed, please try signing in"
|
37
|
+
expired: "Your confirmation token has expired. Please request a new one."
|
38
|
+
invalid_token: "Invalid confirmation token."
|
39
|
+
not_found: "Email not found."
|
40
|
+
new:
|
41
|
+
resend_confirmation_instructions: "Resend confirmation instructions"
|
42
|
+
|
43
|
+
shared:
|
44
|
+
links:
|
45
|
+
sign_in: "Log in"
|
46
|
+
sign_up: "Sign up"
|
47
|
+
forgot_your_password: "Forgot your password?"
|
48
|
+
didn_t_receive_confirmation_instructions: "Didn't receive confirmation instructions?"
|
49
|
+
didn_t_receive_unlock_instructions: "Didn't receive unlock instructions?"
|
50
|
+
|
51
|
+
mailer:
|
52
|
+
confirmation_instructions:
|
53
|
+
subject: "Confirmation instructions"
|
54
|
+
reset_password_instructions:
|
55
|
+
subject: "Reset password instructions"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
es:
|
2
|
+
lockify:
|
3
|
+
sessions:
|
4
|
+
signed_in: "Sesión iniciada correctamente."
|
5
|
+
signed_out: "Sesión cerrada correctamente."
|
6
|
+
invalid: "Email o contraseña inválidos."
|
7
|
+
unconfirmed: "Tienes que confirmar tu dirección de correo electrónico antes de continuar."
|
8
|
+
locked: "Tu cuenta está bloqueada."
|
9
|
+
new:
|
10
|
+
sign_in: "Iniciar sesión"
|
11
|
+
|
12
|
+
registrations:
|
13
|
+
signed_up: "¡Bienvenido! Te has registrado correctamente."
|
14
|
+
signed_up_but_unconfirmed: "Se ha enviado un mensaje con un enlace de confirmación a tu dirección de correo electrónico. Por favor, sigue el enlace para activar tu cuenta."
|
15
|
+
updated: "Tu cuenta se ha actualizado correctamente."
|
16
|
+
destroyed: "¡Adiós! Tu cuenta ha sido cancelada correctamente. Esperamos verte de nuevo pronto."
|
17
|
+
new:
|
18
|
+
sign_up: "Registrarse"
|
19
|
+
|
20
|
+
passwords:
|
21
|
+
send_instructions: "Recibirás un correo electrónico con instrucciones sobre cómo restablecer tu contraseña en unos minutos."
|
22
|
+
updated: "Tu contraseña ha sido cambiada correctamente. Ahora has iniciado sesión."
|
23
|
+
expired: "Tu token de restablecimiento de contraseña ha expirado. Por favor, solicita uno nuevo."
|
24
|
+
new:
|
25
|
+
forgot_your_password: "¿Olvidaste tu contraseña?"
|
26
|
+
send_me_reset_password_instructions: "Enviarme instrucciones para restablecer contraseña"
|
27
|
+
edit:
|
28
|
+
change_your_password: "Cambiar tu contraseña"
|
29
|
+
new_password: "Nueva contraseña"
|
30
|
+
confirm_new_password: "Confirmar nueva contraseña"
|
31
|
+
change_my_password: "Cambiar mi contraseña"
|
32
|
+
|
33
|
+
confirmations:
|
34
|
+
confirmed: "Tu dirección de correo electrónico ha sido confirmada correctamente."
|
35
|
+
send_instructions: "Recibirás un correo electrónico con instrucciones sobre cómo confirmar tu dirección de correo electrónico en unos minutos."
|
36
|
+
already_confirmed: "ya fue confirmado, por favor intenta iniciar sesión"
|
37
|
+
expired: "Tu token de confirmación ha expirado. Por favor, solicita uno nuevo."
|
38
|
+
invalid_token: "Token de confirmación inválido."
|
39
|
+
not_found: "Correo electrónico no encontrado."
|
40
|
+
new:
|
41
|
+
resend_confirmation_instructions: "Reenviar instrucciones de confirmación"
|
42
|
+
|
43
|
+
shared:
|
44
|
+
links:
|
45
|
+
sign_in: "Iniciar sesión"
|
46
|
+
sign_up: "Registrarse"
|
47
|
+
forgot_your_password: "¿Olvidaste tu contraseña?"
|
48
|
+
didn_t_receive_confirmation_instructions: "¿No recibiste las instrucciones de confirmación?"
|
49
|
+
didn_t_receive_unlock_instructions: "¿No recibiste las instrucciones de desbloqueo?"
|
50
|
+
|
51
|
+
mailer:
|
52
|
+
confirmation_instructions:
|
53
|
+
subject: "Instrucciones de confirmación"
|
54
|
+
reset_password_instructions:
|
55
|
+
subject: "Instrucciones para restablecer contraseña"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
devise_scope :user do
|
3
|
+
# Sessions
|
4
|
+
get '/users/sign_in', to: 'users/sessions#new', as: :new_user_session
|
5
|
+
post '/users/sign_in', to: 'users/sessions#create', as: :user_session
|
6
|
+
delete '/users/sign_out', to: 'users/sessions#destroy', as: :destroy_user_session
|
7
|
+
|
8
|
+
# Registrations
|
9
|
+
get '/users/sign_up', to: 'users/registrations#new', as: :new_user_registration
|
10
|
+
post '/users', to: 'users/registrations#create', as: :user_registration
|
11
|
+
get '/users/edit', to: 'users/registrations#edit', as: :edit_user_registration
|
12
|
+
patch '/users', to: 'users/registrations#update'
|
13
|
+
put '/users', to: 'users/registrations#update'
|
14
|
+
delete '/users', to: 'users/registrations#destroy'
|
15
|
+
|
16
|
+
# Passwords
|
17
|
+
get '/users/password/new', to: 'users/passwords#new', as: :new_user_password
|
18
|
+
post '/users/password', to: 'users/passwords#create', as: :user_password
|
19
|
+
get '/users/password/edit', to: 'users/passwords#edit', as: :edit_user_password
|
20
|
+
patch '/users/password', to: 'users/passwords#update'
|
21
|
+
put '/users/password', to: 'users/passwords#update'
|
22
|
+
|
23
|
+
# Confirmations
|
24
|
+
get '/users/confirmation/new', to: 'users/confirmations#new', as: :new_user_confirmation
|
25
|
+
post '/users/confirmation', to: 'users/confirmations#create', as: :user_confirmation
|
26
|
+
get '/users/confirmation', to: 'users/confirmations#show'
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/active_record'
|
3
|
+
|
4
|
+
module Lockify
|
5
|
+
module Generators
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
include ActiveRecord::Generators::Migration
|
8
|
+
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
|
11
|
+
def create_migration
|
12
|
+
migration_template "migration.rb", "db/migrate/add_lockify_to_users.rb"
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_lockify_to_user_model
|
16
|
+
inject_into_class "app/models/user.rb", "User" do
|
17
|
+
" include LockifyUser\n"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_has_secure_password
|
22
|
+
unless File.read("app/models/user.rb").include?("has_secure_password")
|
23
|
+
inject_into_class "app/models/user.rb", "User" do
|
24
|
+
" has_secure_password\n"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_update_without_password_method
|
30
|
+
inject_into_class "app/models/user.rb", "User" do
|
31
|
+
<<~RUBY
|
32
|
+
|
33
|
+
def update_without_password(params)
|
34
|
+
params.delete(:password)
|
35
|
+
params.delete(:password_confirmation)
|
36
|
+
update(params)
|
37
|
+
end
|
38
|
+
RUBY
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_devise_mapping_helper
|
43
|
+
create_file "app/helpers/devise_helper.rb", <<~RUBY
|
44
|
+
module DeviseHelper
|
45
|
+
def devise_mapping
|
46
|
+
@devise_mapping ||= OpenStruct.new(
|
47
|
+
registerable?: true,
|
48
|
+
recoverable?: true,
|
49
|
+
confirmable?: User.column_names.include?('confirmation_token'),
|
50
|
+
lockable?: User.column_names.include?('locked_at'),
|
51
|
+
rememberable?: User.column_names.include?('remember_token')
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
def resource_class
|
56
|
+
User
|
57
|
+
end
|
58
|
+
|
59
|
+
def resource_name
|
60
|
+
:user
|
61
|
+
end
|
62
|
+
|
63
|
+
def devise_error_messages!
|
64
|
+
return "" if resource.errors.empty?
|
65
|
+
|
66
|
+
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
|
67
|
+
sentence = I18n.t("errors.messages.not_saved",
|
68
|
+
count: resource.errors.count,
|
69
|
+
resource: resource.class.model_name.human.downcase)
|
70
|
+
|
71
|
+
html = <<-HTML
|
72
|
+
<div id="error_explanation">
|
73
|
+
<h2>\#{sentence}</h2>
|
74
|
+
<ul>\#{messages}</ul>
|
75
|
+
</div>
|
76
|
+
HTML
|
77
|
+
|
78
|
+
html.html_safe
|
79
|
+
end
|
80
|
+
end
|
81
|
+
RUBY
|
82
|
+
end
|
83
|
+
|
84
|
+
def show_readme
|
85
|
+
readme "README" if behavior == :invoke
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def readme(path)
|
91
|
+
say File.read(File.join(File.dirname(__FILE__), "templates", path))
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Lockify has been installed successfully!
|
4
|
+
|
5
|
+
Next steps:
|
6
|
+
|
7
|
+
1. Run the migration:
|
8
|
+
rails db:migrate
|
9
|
+
|
10
|
+
2. Configure your mailer settings in config/environments/development.rb:
|
11
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
12
|
+
|
13
|
+
3. Your User model has been updated with Lockify functionality.
|
14
|
+
|
15
|
+
4. Remove any Devise references from your routes.rb file if they exist.
|
16
|
+
|
17
|
+
5. Update your views (optional):
|
18
|
+
rails generate lockify:views
|
19
|
+
|
20
|
+
Routes available (same as Devise):
|
21
|
+
- /users/sign_in
|
22
|
+
- /users/sign_up
|
23
|
+
- /users/sign_out
|
24
|
+
- /users/password/new
|
25
|
+
- /users/password/edit
|
26
|
+
- /users/confirmation
|
27
|
+
|
28
|
+
Helpers available (same as Devise):
|
29
|
+
- current_user
|
30
|
+
- user_signed_in?
|
31
|
+
- authenticate_user!
|
32
|
+
- sign_in(user)
|
33
|
+
- sign_out
|
34
|
+
|
35
|
+
Your application should now work exactly as it did with Devise!
|
36
|
+
|
37
|
+
===============================================================================
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class AddLockifyToUsers < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
|
+
def change
|
3
|
+
# Rename encrypted_password to password_digest if it exists
|
4
|
+
if column_exists?(:users, :encrypted_password)
|
5
|
+
rename_column :users, :encrypted_password, :password_digest
|
6
|
+
else
|
7
|
+
add_column :users, :password_digest, :string unless column_exists?(:users, :password_digest)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Add confirmation fields if they don't exist
|
11
|
+
unless column_exists?(:users, :confirmation_token)
|
12
|
+
add_column :users, :confirmation_token, :string
|
13
|
+
add_column :users, :confirmed_at, :datetime
|
14
|
+
add_column :users, :confirmation_sent_at, :datetime
|
15
|
+
add_index :users, :confirmation_token, unique: true
|
16
|
+
end
|
17
|
+
|
18
|
+
# Add reset password fields if they don't exist
|
19
|
+
unless column_exists?(:users, :reset_password_token)
|
20
|
+
add_column :users, :reset_password_token, :string
|
21
|
+
add_column :users, :reset_password_sent_at, :datetime
|
22
|
+
add_index :users, :reset_password_token, unique: true
|
23
|
+
end
|
24
|
+
|
25
|
+
# Add remember token fields if they don't exist
|
26
|
+
unless column_exists?(:users, :remember_token)
|
27
|
+
add_column :users, :remember_token, :string
|
28
|
+
add_column :users, :remember_created_at, :datetime
|
29
|
+
add_index :users, :remember_token, unique: true
|
30
|
+
end
|
31
|
+
|
32
|
+
# Add lockable fields if they don't exist
|
33
|
+
unless column_exists?(:users, :failed_attempts)
|
34
|
+
add_column :users, :failed_attempts, :integer, default: 0, null: false
|
35
|
+
add_column :users, :locked_at, :datetime
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Lockify
|
4
|
+
module Generators
|
5
|
+
class ViewsGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('../../../../app/views/lockify', __dir__)
|
7
|
+
|
8
|
+
def copy_views
|
9
|
+
directory ".", "app/views/users"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Lockify
|
2
|
+
module Controllers
|
3
|
+
module Helpers
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
helper_method :current_user, :user_signed_in?, :user_session
|
8
|
+
end
|
9
|
+
|
10
|
+
def current_user
|
11
|
+
@current_user ||= find_user_from_session || find_user_from_remember_token
|
12
|
+
end
|
13
|
+
|
14
|
+
def user_signed_in?
|
15
|
+
!!current_user
|
16
|
+
end
|
17
|
+
|
18
|
+
def user_session
|
19
|
+
session
|
20
|
+
end
|
21
|
+
|
22
|
+
def authenticate_user!
|
23
|
+
unless user_signed_in?
|
24
|
+
store_user_location!
|
25
|
+
redirect_to new_user_session_path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def sign_in(resource, options = {})
|
30
|
+
session[:user_id] = resource.id
|
31
|
+
if options[:remember_me]
|
32
|
+
resource.remember_me!
|
33
|
+
cookies.permanent.encrypted[:remember_user_token] = resource.remember_token
|
34
|
+
end
|
35
|
+
@current_user = resource
|
36
|
+
end
|
37
|
+
|
38
|
+
def sign_out(resource_or_scope = nil)
|
39
|
+
session.delete(:user_id)
|
40
|
+
cookies.delete(:remember_user_token)
|
41
|
+
@current_user = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def store_user_location!
|
45
|
+
store_location_for(:user, request.fullpath) if request.get?
|
46
|
+
end
|
47
|
+
|
48
|
+
def store_location_for(resource_or_scope, location)
|
49
|
+
session["#{resource_or_scope}_return_to"] = location
|
50
|
+
end
|
51
|
+
|
52
|
+
def stored_location_for(resource_or_scope)
|
53
|
+
session.delete("#{resource_or_scope}_return_to")
|
54
|
+
end
|
55
|
+
|
56
|
+
def after_sign_in_path_for(resource_or_scope)
|
57
|
+
stored_location_for(resource_or_scope) || root_path
|
58
|
+
end
|
59
|
+
|
60
|
+
def after_sign_out_path_for(resource_or_scope)
|
61
|
+
root_path
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def find_user_from_session
|
67
|
+
User.find_by(id: session[:user_id]) if session[:user_id]
|
68
|
+
end
|
69
|
+
|
70
|
+
def find_user_from_remember_token
|
71
|
+
return unless cookies.encrypted[:remember_user_token]
|
72
|
+
User.find_by(remember_token: cookies.encrypted[:remember_user_token])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Lockify
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace Lockify
|
4
|
+
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec
|
7
|
+
end
|
8
|
+
|
9
|
+
initializer "lockify.helpers" do
|
10
|
+
ActiveSupport.on_load(:action_controller_base) do
|
11
|
+
include Lockify::Controllers::Helpers
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
initializer "lockify.routes", after: :add_routing_paths do
|
16
|
+
Rails.application.routes.prepend do
|
17
|
+
# Sessions
|
18
|
+
get '/users/sign_in', to: 'users/sessions#new', as: :new_user_session
|
19
|
+
post '/users/sign_in', to: 'users/sessions#create', as: :user_session
|
20
|
+
delete '/users/sign_out', to: 'users/sessions#destroy', as: :destroy_user_session
|
21
|
+
|
22
|
+
# Registrations
|
23
|
+
get '/users/sign_up', to: 'users/registrations#new', as: :new_user_registration
|
24
|
+
post '/users', to: 'users/registrations#create', as: :user_registration
|
25
|
+
get '/users/edit', to: 'users/registrations#edit', as: :edit_user_registration
|
26
|
+
patch '/users', to: 'users/registrations#update'
|
27
|
+
put '/users', to: 'users/registrations#update'
|
28
|
+
delete '/users', to: 'users/registrations#destroy'
|
29
|
+
|
30
|
+
# Passwords
|
31
|
+
get '/users/password/new', to: 'users/passwords#new', as: :new_user_password
|
32
|
+
post '/users/password', to: 'users/passwords#create', as: :user_password
|
33
|
+
get '/users/password/edit', to: 'users/passwords#edit', as: :edit_user_password
|
34
|
+
patch '/users/password', to: 'users/passwords#update'
|
35
|
+
put '/users/password', to: 'users/passwords#update'
|
36
|
+
|
37
|
+
# Confirmations
|
38
|
+
get '/users/confirmation/new', to: 'users/confirmations#new', as: :new_user_confirmation
|
39
|
+
post '/users/confirmation', to: 'users/confirmations#create', as: :user_confirmation
|
40
|
+
get '/users/confirmation', to: 'users/confirmations#show'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/lockify.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "lockify/version"
|
2
|
+
require "lockify/engine"
|
3
|
+
require "lockify/controllers/helpers"
|
4
|
+
|
5
|
+
module Lockify
|
6
|
+
mattr_accessor :password_length
|
7
|
+
@@password_length = 6..128
|
8
|
+
|
9
|
+
mattr_accessor :email_regexp
|
10
|
+
@@email_regexp = /\A[^@\s]+@[^@\s]+\z/
|
11
|
+
|
12
|
+
mattr_accessor :reset_password_within
|
13
|
+
@@reset_password_within = 6.hours
|
14
|
+
|
15
|
+
mattr_accessor :confirm_within
|
16
|
+
@@confirm_within = nil
|
17
|
+
|
18
|
+
mattr_accessor :remember_for
|
19
|
+
@@remember_for = 2.weeks
|
20
|
+
|
21
|
+
mattr_accessor :timeout_in
|
22
|
+
@@timeout_in = 30.minutes
|
23
|
+
|
24
|
+
mattr_accessor :maximum_attempts
|
25
|
+
@@maximum_attempts = 20
|
26
|
+
|
27
|
+
mattr_accessor :unlock_in
|
28
|
+
@@unlock_in = 1.hour
|
29
|
+
|
30
|
+
def self.setup
|
31
|
+
yield(self)
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lockify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Liz
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: rails
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 7.0.0
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 7.0.0
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: bcrypt
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.1.7
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 3.1.7
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: rspec-rails
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
description: Complete authentication system compatible with Devise
|
55
|
+
email:
|
56
|
+
- soyprogramador.liz.mx@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- MIT-LICENSE
|
62
|
+
- README.md
|
63
|
+
- Rakefile
|
64
|
+
- app/controllers/users/confirmations_controller.rb
|
65
|
+
- app/controllers/users/passwords_controller.rb
|
66
|
+
- app/controllers/users/registrations_controller.rb
|
67
|
+
- app/controllers/users/sessions_controller.rb
|
68
|
+
- app/mailers/user_mailer.rb
|
69
|
+
- app/models/concerns/lockify_user.rb
|
70
|
+
- app/views/lockify/confirmations/new.html.erb
|
71
|
+
- app/views/lockify/passwords/edit.html.erb
|
72
|
+
- app/views/lockify/passwords/new.html.erb
|
73
|
+
- app/views/lockify/registrations/new.html.erb
|
74
|
+
- app/views/lockify/sessions/new.html.erb
|
75
|
+
- app/views/lockify/shared/_error_messages.html.erb
|
76
|
+
- app/views/lockify/shared/_links.html.erb
|
77
|
+
- config/locales/en.yml
|
78
|
+
- config/locales/es.yml
|
79
|
+
- config/routes.rb
|
80
|
+
- lib/generators/lockify/install/install_generator.rb
|
81
|
+
- lib/generators/lockify/install/templates/README
|
82
|
+
- lib/generators/lockify/install/templates/migration.rb
|
83
|
+
- lib/generators/lockify/views/views_generator.rb
|
84
|
+
- lib/lockify.rb
|
85
|
+
- lib/lockify/controllers/helpers.rb
|
86
|
+
- lib/lockify/engine.rb
|
87
|
+
- lib/lockify/version.rb
|
88
|
+
homepage: https://soyprogramador.liz.mx/lockify
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubygems_version: 3.6.9
|
107
|
+
specification_version: 4
|
108
|
+
summary: Drop-in replacement for Devise in Rails 8
|
109
|
+
test_files: []
|