authentication-zero 0.0.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.
Files changed (32) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/CHANGELOG.md +0 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +34 -0
  8. data/Rakefile +2 -0
  9. data/authentication-zero.gemspec +22 -0
  10. data/lib/authentication-zero.rb +1 -0
  11. data/lib/authentication_zero/version.rb +3 -0
  12. data/lib/authentication_zero.rb +4 -0
  13. data/lib/generators/authentication/USAGE +6 -0
  14. data/lib/generators/authentication/authentication_generator.rb +64 -0
  15. data/lib/generators/authentication/templates/controllers/html/cancellations_controller.rb.tt +10 -0
  16. data/lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt +38 -0
  17. data/lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt +20 -0
  18. data/lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt +23 -0
  19. data/lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt +29 -0
  20. data/lib/generators/authentication/templates/mailers/password_mailer.rb.tt +6 -0
  21. data/lib/generators/authentication/templates/migration.rb.tt +14 -0
  22. data/lib/generators/authentication/templates/models/current.rb.tt +3 -0
  23. data/lib/generators/authentication/templates/models/resource.rb.tt +10 -0
  24. data/lib/generators/authentication/templates/views/html/cancellations/new.html.erb.tt +11 -0
  25. data/lib/generators/authentication/templates/views/html/password_mailer/reset.html.erb.tt +7 -0
  26. data/lib/generators/authentication/templates/views/html/password_mailer/reset.text.erb.tt +7 -0
  27. data/lib/generators/authentication/templates/views/html/password_resets/edit.html.erb.tt +36 -0
  28. data/lib/generators/authentication/templates/views/html/password_resets/new.html.erb.tt +21 -0
  29. data/lib/generators/authentication/templates/views/html/passwords/edit.html.erb.tt +42 -0
  30. data/lib/generators/authentication/templates/views/html/registrations/new.html.erb.tt +40 -0
  31. data/lib/generators/authentication/templates/views/html/sessions/new.html.erb.tt +32 -0
  32. metadata +76 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: edcfb4270bbf35bdd9a0eeee95e9cc939d4e0254dea271d6fcdf3114b9c69c78
4
+ data.tar.gz: e7c715c92ab3fd57f209c7a4db1e14f76b65551098c2e65207184d45457b85fa
5
+ SHA512:
6
+ metadata.gz: c397a19049d0c44bef77ee1afe15966a3c51f3c53c5480e937dba4579ffd28f6eff178b54f2273aa32839a3d5ee4cc55f6bc8ca625e02ded7eec989af6be324f
7
+ data.tar.gz: 6480cdc0b5f82da1d38c342fd27af1ab3948dbf67cb20d415123cdacaebdd6a4e1f338768f401566d9f8b1082eeb19cc28475578264e44a1136af95cc7aa2c1d
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/CHANGELOG.md ADDED
File without changes
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at lazaronixon@hotmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in authentication_zero.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Nixon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Authentication Zero
2
+
3
+ The purpose of authentication zero is to generate a pre-built authentication system into a rails application that follows both security and rails best practices. By generating code into the user's application instead of using a library, the user has complete freedom to modify the authentication system so it works best with their app.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'authentication-zero'
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```
16
+ $ rails generate authentication user
17
+ ```
18
+
19
+ ## Development
20
+
21
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
22
+
23
+ ## Contributing
24
+
25
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lazaronixon/authentication-zero. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/lazaronixon/authentication-zero/blob/main/CODE_OF_CONDUCT.md).
26
+
27
+
28
+ ## License
29
+
30
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
31
+
32
+ ## Code of Conduct
33
+
34
+ Everyone interacting in the AuthenticationZero project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/lazaronixon/authentication-zero/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,22 @@
1
+ require_relative 'lib/authentication_zero/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "authentication-zero"
5
+ spec.version = AuthenticationZero::VERSION
6
+ spec.authors = ["Nixon"]
7
+ spec.email = ["lazaronixon@hotmail.com"]
8
+
9
+ spec.summary = "An authentication system generator for Rails applications"
10
+ spec.homepage = "https://github.com/lazaronixon/authentication-zero"
11
+ spec.license = "MIT"
12
+
13
+ spec.metadata["homepage_uri"] = spec.homepage
14
+ spec.metadata["source_code_uri"] = "https://github.com/lazaronixon/authentication-zero"
15
+ spec.metadata["changelog_uri"] = "https://github.com/lazaronixon/authentication-zero/blob/main/CHANGELOG.md"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ end
@@ -0,0 +1 @@
1
+ require "authentication_zero"
@@ -0,0 +1,3 @@
1
+ module AuthenticationZero
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "authentication_zero/version"
2
+
3
+ module AuthenticationZero
4
+ end
@@ -0,0 +1,6 @@
1
+ Description:
2
+ The purpose of authentication zero is to generate a pre-built authentication system into a rails application that follows both security and rails best practices.
3
+ By generating code into the user's application instead of using a library, the user has complete freedom to modify the authentication system so it works best with their app.
4
+
5
+ Example:
6
+ bin/rails generate authentication user
@@ -0,0 +1,64 @@
1
+ require "rails/generators/active_record"
2
+
3
+ class AuthenticationGenerator < Rails::Generators::NamedBase
4
+ include ActiveRecord::Generators::Migration
5
+
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ def uncomment_bcrypt
9
+ uncomment_lines 'Gemfile', /bcrypt/
10
+ end
11
+
12
+ def create_controllers
13
+ directory "controllers/html", "app/controllers"
14
+ end
15
+
16
+ def create_mailers
17
+ template "mailers/password_mailer.rb", "app/mailers/password_mailer.rb"
18
+ end
19
+
20
+ def create_views
21
+ directory "views/html", "app/views"
22
+ end
23
+
24
+ def create_models
25
+ template "models/current.rb", "app/models/current.rb"
26
+ template "models/resource.rb", "app/models/#{singular_table_name}.rb"
27
+ end
28
+
29
+ def create_migrations
30
+ migration_template "migration.rb", "#{db_migrate_path}/create_#{file_name}.rb"
31
+ end
32
+
33
+ def add_routes
34
+ route "get 'sign_up', to: 'registrations#new'"
35
+ route "post 'sign_up', to: 'registrations#create'"
36
+ route "get 'sign_in', to: 'sessions#new'"
37
+ route "post 'sign_in', to: 'sessions#create'"
38
+ route "get 'password/edit', to: 'passwords#edit'"
39
+ route "patch 'password', to: 'passwords#update'"
40
+ route "get 'cancellation/new', to: 'cancellations#new'"
41
+ route "post 'cancellation', to: 'cancellations#destroy'"
42
+ route "get 'password_reset/new', to: 'password_resets#new'"
43
+ route "post 'password_reset', to: 'password_resets#create'"
44
+ route "get 'password_reset/edit', to: 'password_resets#edit'"
45
+ route "patch 'password_reset', to: 'password_resets#update'"
46
+ route "delete 'sign_out', to: 'sessions#destroy'"
47
+ end
48
+
49
+ def add_application_controller_methods
50
+ inject_into_class "app/controllers/application_controller.rb", "ApplicationController", verbose: false do <<~CODE
51
+ before_action :authenticate
52
+
53
+ private
54
+ def authenticate
55
+ if #{singular_table_name} = cookies[:session_token] && #{class_name}.find_by_session_token(cookies[:session_token])
56
+ Current.user = #{singular_table_name}
57
+ else
58
+ redirect_to sign_in_path, alert: "You need to sign in or sign up before continuing"
59
+ end
60
+ end
61
+ CODE
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,10 @@
1
+ class CancellationsController < ApplicationController
2
+ def new
3
+ end
4
+
5
+ def destroy
6
+ Current.<%= singular_table_name %>.destroy
7
+ cookies.delete :session_token
8
+ redirect_to sign_in_path, notice: "Bye! Your account has been successfully cancelled"
9
+ end
10
+ end
@@ -0,0 +1,38 @@
1
+ class PasswordResetsController < ApplicationController
2
+ before_action :set_<%= singular_table_name %>, only: %i[ edit update ]
3
+ skip_before_action :authenticate
4
+
5
+ def new
6
+ end
7
+
8
+ def edit
9
+ end
10
+
11
+ def create
12
+ if @<%= singular_table_name %> = <%= class_name %>.find_by_email(params[:email])
13
+ PasswordMailer.with(to: @<%= singular_table_name %>).reset.deliver_later
14
+ redirect_to sign_in_path, notice: "You will receive an email with instructions on how to reset your password in a few minutes"
15
+ else
16
+ redirect_to password_reset_new_path, alert: "The email address doesn't exist in our database"
17
+ end
18
+ end
19
+
20
+ def update
21
+ if @<%= singular_table_name %>.update(password_params)
22
+ redirect_to sign_in_path, notice: "Your password was reset successfully. Please sign in"
23
+ else
24
+ render :edit, status: :unprocessable_entity
25
+ end
26
+ end
27
+
28
+ private
29
+ def set_<%= singular_table_name %>
30
+ @<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:token], purpose: "password_reset")
31
+ rescue ActiveSupport::MessageVerifier::InvalidSignature
32
+ redirect_to sign_in_path, alert: "Your token has expired, please request a new one"
33
+ end
34
+
35
+ def password_params
36
+ params.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ class PasswordsController < ApplicationController
2
+ def edit
3
+ @<%= singular_table_name %> = Current.<%= singular_table_name %>
4
+ end
5
+
6
+ def update
7
+ if !Current.<%= singular_table_name %>.authenticate(params[:current_password])
8
+ redirect_to password_edit_path, alert: "The current password you entered is incorrect"
9
+ elsif Current.<%= singular_table_name %>.update(password_params)
10
+ redirect_to root_path, notice: "Your password has been changed successfully"
11
+ else
12
+ render :edit, status: :unprocessable_entity
13
+ end
14
+ end
15
+
16
+ private
17
+ def password_params
18
+ params.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ class RegistrationsController < ApplicationController
2
+ skip_before_action :authenticate
3
+
4
+ def new
5
+ @<%= singular_table_name %> = <%= class_name %>.new
6
+ end
7
+
8
+ def create
9
+ @<%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)
10
+
11
+ if @<%= singular_table_name %>.save
12
+ cookies[:session_token] = { value: @<%= singular_table_name %>.session_token, httponly: true }
13
+ redirect_to root_path, notice: "Welcome! You have signed up successfully"
14
+ else
15
+ render :new, status: :unprocessable_entity
16
+ end
17
+ end
18
+
19
+ private
20
+ def <%= "#{singular_table_name}_params" %>
21
+ params.require(:<%= singular_table_name %>).permit(:email, :password, :password_confirmation)
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ class SessionsController < ApplicationController
2
+ skip_before_action :authenticate, except: :destroy
3
+
4
+ def new
5
+ @<%= singular_table_name %> = <%= class_name %>.new
6
+ end
7
+
8
+ def create
9
+ @<%= singular_table_name %> = <%= class_name %>.find_by_email(params[:email])
10
+
11
+ if @<%= singular_table_name %>.try(:authenticate, params[:password])
12
+ if params[:remember_me] == "1"
13
+ cookies.permanent[:session_token] = { value: @<%= singular_table_name %>.session_token, httponly: true }
14
+ else
15
+ cookies[:session_token] = { value: @<%= singular_table_name %>.session_token, httponly: true }
16
+ end
17
+
18
+ redirect_to root_path, notice: "Signed in successfully"
19
+ else
20
+ redirect_to sign_in_path(email_hint: params[:email]), alert: "Invalid email or password"
21
+ end
22
+ end
23
+
24
+ def destroy
25
+ cookies.delete :session_token
26
+ Current.<%= singular_table_name %>.regenerate_session_token
27
+ redirect_to sign_in_path, notice: "Signed out successfully"
28
+ end
29
+ end
@@ -0,0 +1,6 @@
1
+ class PasswordMailer < ApplicationMailer
2
+ def reset
3
+ @token = params[:<%= singular_table_name %>].signed_id(purpose: "password_reset", expires_in: 15.minutes)
4
+ mail to: params[:<%= singular_table_name %>].email
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
+ def change
3
+ create_table :<%= table_name %> do |t|
4
+ t.string :email, null: false
5
+ t.string :password_digest, null: false
6
+ t.string :session_token, null: false
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :<%= table_name %>, :email, unique: true
12
+ add_index :<%= table_name %>, :session_token, unique: true
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ class Current < ActiveSupport::CurrentAttributes
2
+ attribute :<%= singular_table_name %>
3
+ end
@@ -0,0 +1,10 @@
1
+ class <%= class_name %> < ApplicationRecord
2
+ has_secure_password :password
3
+ has_secure_token :session_token
4
+
5
+ validates :email, presence: true, uniqueness: true
6
+ validates :email, format: { with: /\A[^@\s]+@[^@\s]+\z/ }
7
+ validates :password, length: 8..70, allow_blank: true
8
+
9
+ before_validation { self.email = email.downcase.strip }
10
+ end
@@ -0,0 +1,11 @@
1
+ <h1>Want to close your account?</h1>
2
+
3
+ <p>Your account will be immediately closed. You won’t be able to sign in anymore.</p>
4
+ <p>Your data will be permanently deleted from our servers.</p>
5
+ <p><%%= link_to "Back", :back %></p>
6
+
7
+ <br>
8
+
9
+ <div>
10
+ <%%= button_to "OK, close my account", cancellation_path, method: :post %>
11
+ </div>
@@ -0,0 +1,7 @@
1
+ Hi <%%= params[:<%= singular_table_name %>].email %>,
2
+
3
+ Someone requested a reset of your password.
4
+
5
+ If this was you, click the link to reset your password. The link will expire automatically in 15 minutes.
6
+
7
+ <%%= link_to "Reset password", password_reset_edit_url(token: @token) %>
@@ -0,0 +1,7 @@
1
+ Hi <%%= params[:<%= singular_table_name %>].email %>,
2
+
3
+ Someone requested a reset of your password.
4
+
5
+ If this was you, click the link to reset your password. The link will expire automatically in 15 minutes.
6
+
7
+ <%%= password_reset_edit_url(token: @token) %>
@@ -0,0 +1,36 @@
1
+ <h1>Reset your password</h1>
2
+
3
+ <%%= form_with(model: @<%= model_resource_name %>, url: password_reset_path(token: params[:token])) do |form| %>
4
+ <%% if @<%= singular_table_name %>.errors.any? %>
5
+ <div style="color: red">
6
+ <h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
7
+
8
+ <ul>
9
+ <%% @<%= singular_table_name %>.errors.each do |error| %>
10
+ <li><%%= error.full_message %></li>
11
+ <%% end %>
12
+ </ul>
13
+ </div>
14
+ <%% end %>
15
+
16
+ <div>
17
+ <%%= form.label :password, "New password (6 characters minimum)", style: "display: block" %>
18
+ <%%= form.password_field :password, autofocus: true, autocomplete: "new-password" %>
19
+ </div>
20
+
21
+ <div>
22
+ <%%= form.label :password_confirmation, style: "display: block" %>
23
+ <%%= form.password_field :password_confirmation, autocomplete: "new-password" %>
24
+ </div>
25
+
26
+ <div>
27
+ <%%= form.submit "Reset password" %>
28
+ </div>
29
+ <%% end %>
30
+
31
+ <br>
32
+
33
+ <div>
34
+ <%%= link_to "Sign in", sign_in_path %> |
35
+ <%%= link_to "Sign up", sign_up_path %>
36
+ </div>
@@ -0,0 +1,21 @@
1
+ <p style="color: red"><%%= alert %></p>
2
+
3
+ <h1>Forgot your password?</h1>
4
+
5
+ <%%= form_with(url: password_reset_path) do |form| %>
6
+ <div>
7
+ <%%= form.label :email, style: "display: block" %>
8
+ <%%= form.email_field :email, autofocus: true, required: true, autocomplete: "email" %>
9
+ </div>
10
+
11
+ <div>
12
+ <%%= form.submit "Send password reset email" %>
13
+ </div>
14
+ <%% end %>
15
+
16
+ <br>
17
+
18
+ <div>
19
+ <%%= link_to "Sign in", sign_in_path %> |
20
+ <%%= link_to "Sign up", sign_up_path %>
21
+ </div>
@@ -0,0 +1,42 @@
1
+ <p style="color: red"><%%= alert %></p>
2
+
3
+ <h1>Change your password</h1>
4
+
5
+ <%%= form_with(model: @<%= model_resource_name %>, url: password_path) do |form| %>
6
+ <%% if @<%= singular_table_name %>.errors.any? %>
7
+ <div style="color: red">
8
+ <h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
9
+
10
+ <ul>
11
+ <%% @<%%= singular_table_name %>.errors.each do |error| %>
12
+ <li><%%= error.full_message %></li>
13
+ <%% end %>
14
+ </ul>
15
+ </div>
16
+ <%% end %>
17
+
18
+ <div>
19
+ <%%= label_tag :current_password, nil, style: "display: block" %>
20
+ <%%= password_field_tag :current_password, autofocus: true, autocomplete: "current-password" %>
21
+ </div>
22
+
23
+ <div>
24
+ <%%= form.label :password, "New password (6 characters minimum)", style: "display: block" %>
25
+ <%%= form.password_field :password, autocomplete: "new-password" %>
26
+ </div>
27
+
28
+ <div>
29
+ <%%= form.label :password_confirmation, style: "display: block" %>
30
+ <%%= form.password_field :password_confirmation, autocomplete: "new-password" %>
31
+ </div>
32
+
33
+ <div>
34
+ <%%= form.submit "Save changes" %>
35
+ </div>
36
+ <%% end %>
37
+
38
+ <br>
39
+
40
+ <div>
41
+ <%%= link_to "Back", :back %>
42
+ </div>
@@ -0,0 +1,40 @@
1
+ <h1>Sign up</h1>
2
+
3
+ <%%= form_with(model: @<%= model_resource_name %>, url: sign_up_path) do |form| %>
4
+ <%% if @<%= singular_table_name %>.errors.any? %>
5
+ <div style="color: red">
6
+ <h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
7
+
8
+ <ul>
9
+ <%% @<%= singular_table_name %>.errors.each do |error| %>
10
+ <li><%%= error.full_message %></li>
11
+ <%% end %>
12
+ </ul>
13
+ </div>
14
+ <%% end %>
15
+
16
+ <div>
17
+ <%%= form.label :email, style: "display: block" %>
18
+ <%%= form.email_field :email, autofocus: true, autocomplete: "email" %>
19
+ </div>
20
+
21
+ <div>
22
+ <%%= form.label :password, "Password (6 characters minimum)", style: "display: block" %>
23
+ <%%= form.password_field :password, autocomplete: "new-password" %>
24
+ </div>
25
+
26
+ <div>
27
+ <%%= form.label :password_confirmation, style: "display: block" %>
28
+ <%%= form.password_field :password_confirmation, autocomplete: "new-password" %>
29
+ </div>
30
+
31
+ <div>
32
+ <%%= form.submit "Sign up" %>
33
+ </div>
34
+ <%% end %>
35
+
36
+ <br>
37
+
38
+ <div>
39
+ <%%= link_to "Sign in", sign_in_path %>
40
+ </div>
@@ -0,0 +1,32 @@
1
+ <p style="color: green"><%%= notice %></p>
2
+ <p style="color: red"><%%= alert %></p>
3
+
4
+ <h1>Sign in</h1>
5
+
6
+ <%%= form_with(url: sign_in_path) do |form| %>
7
+ <div>
8
+ <%%= form.label :email, style: "display: block" %>
9
+ <%%= form.email_field :email, value: params[:email_hint], autofocus: true, required: true, autocomplete: "email" %>
10
+ </div>
11
+
12
+ <div>
13
+ <%%= form.label :password, style: "display: block" %>
14
+ <%%= form.password_field :password, required: true, autocomplete: "current-password" %>
15
+ </div>
16
+
17
+ <div>
18
+ <%%= form.check_box :remember_me %>
19
+ <%%= form.label :remember_me %>
20
+ </div>
21
+
22
+ <div>
23
+ <%%= form.submit "Sign in" %>
24
+ </div>
25
+ <%% end %>
26
+
27
+ <br>
28
+
29
+ <div>
30
+ <%%= link_to "Sign up", sign_up_path %> |
31
+ <%%= link_to "Forgot your password?", password_reset_new_path %>
32
+ </div>
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: authentication-zero
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nixon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - lazaronixon@hotmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - CHANGELOG.md
22
+ - CODE_OF_CONDUCT.md
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - authentication-zero.gemspec
28
+ - lib/authentication-zero.rb
29
+ - lib/authentication_zero.rb
30
+ - lib/authentication_zero/version.rb
31
+ - lib/generators/authentication/USAGE
32
+ - lib/generators/authentication/authentication_generator.rb
33
+ - lib/generators/authentication/templates/controllers/html/cancellations_controller.rb.tt
34
+ - lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt
35
+ - lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
36
+ - lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
37
+ - lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt
38
+ - lib/generators/authentication/templates/mailers/password_mailer.rb.tt
39
+ - lib/generators/authentication/templates/migration.rb.tt
40
+ - lib/generators/authentication/templates/models/current.rb.tt
41
+ - lib/generators/authentication/templates/models/resource.rb.tt
42
+ - lib/generators/authentication/templates/views/html/cancellations/new.html.erb.tt
43
+ - lib/generators/authentication/templates/views/html/password_mailer/reset.html.erb.tt
44
+ - lib/generators/authentication/templates/views/html/password_mailer/reset.text.erb.tt
45
+ - lib/generators/authentication/templates/views/html/password_resets/edit.html.erb.tt
46
+ - lib/generators/authentication/templates/views/html/password_resets/new.html.erb.tt
47
+ - lib/generators/authentication/templates/views/html/passwords/edit.html.erb.tt
48
+ - lib/generators/authentication/templates/views/html/registrations/new.html.erb.tt
49
+ - lib/generators/authentication/templates/views/html/sessions/new.html.erb.tt
50
+ homepage: https://github.com/lazaronixon/authentication-zero
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ homepage_uri: https://github.com/lazaronixon/authentication-zero
55
+ source_code_uri: https://github.com/lazaronixon/authentication-zero
56
+ changelog_uri: https://github.com/lazaronixon/authentication-zero/blob/main/CHANGELOG.md
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubygems_version: 3.1.4
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: An authentication system generator for Rails applications
76
+ test_files: []