loading
Generated 2025-10-08T23:57:43+00:00

All Files ( 100.0% covered at 6.96 hits/line )

5 files in total.
48 relevant lines, 48 lines covered and 0 lines missed. ( 100.0% )
4 total branches, 4 branches covered and 0 branches missed. ( 100.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line Branch Coverage Branches Covered branches Missed branches
app/views/auther/session/new.html.erb 100.00 % 29 14 14 0 16.71 100.00 % 4 4 0
app/views/layouts/auther/auth.html.erb 100.00 % 20 5 5 0 13.00 100.00 % 0 0 0
lib/generators/auther/credentials/credentials_generator.rb 100.00 % 31 14 14 0 1.00 100.00 % 0 0 0
lib/generators/auther/install/install_generator.rb 100.00 % 27 14 14 0 1.43 100.00 % 0 0 0
lib/generators/auther/templates/config/initializers/auther.rb 100.00 % 13 1 1 0 1.00 100.00 % 0 0 0

app/views/auther/session/new.html.erb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
4 total branches, 4 branches covered and 0 branches missed.
    
  1. 26 <% content_for(:title) { @title } %>
  2. 13
  3. <div class="auther">
  4. <div class="body">
  5. <h1 class="label">Authorization</h1>
  6. 26 <%= form_for @account, as: :account, url: "/auther/session", html: {class: :form} do |form| %>
  7. 26 then: 9 else: 4 <%= content_tag :div, class: %(section #{"error" if @account.error?(:login)}) do %>
  8. <div class="group">
  9. 13 <%= form.text_field :login, class: "input", placeholder: "Login" %>
  10. 13 <small class="message"><%= @account.error_message(:login) %></small>
  11. </div>
  12. <% end %>
  13. 13
  14. 26 then: 1 else: 12 <%= content_tag :div, class: %(section #{"error" if @account.error?(:password)}) do %>
  15. <div class="group">
  16. 13 <%= form.password_field :password, class: "input", placeholder: "Password" %>
  17. 13 <small class="message"><%= @account.error_message(:password) %></small>
  18. </div>
  19. <% end %>
  20. 13
  21. <div class="section">
  22. 13 <%= form.select :name, @account_options, {}, class: "select" %>
  23. </div>
  24. 13 <%= form.submit "Login", class: "button" %>
  25. <% end %>
  26. 13 </div>
  27. </div>

app/views/layouts/auther/auth.html.erb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. 13 <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  5. 13 <title><%= yield :title %></title>
  6. <meta charset="utf-8">
  7. <meta name="description" content="A demo site.">
  8. <meta name="author" content="Alchemists">
  9. 13 <%= stylesheet_link_tag "auther/application", media: "all" %>
  10. 13 <%= csrf_meta_tags %>
  11. </head>
  12. <body>
  13. 13 <%= yield %>
  14. </body>
  15. </html>

lib/generators/auther/credentials/credentials_generator.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module Auther
  3. # Credentials generator for new secret, login, and password.
  4. 1 class CredentialsGenerator < ::Rails::Generators::Base
  5. 1 desc "Generate Auther secret, login, and password credentials."
  6. 1 def credentials
  7. 1 puts "Welcome to the Auther credentials generator.\n"
  8. 1 login = ask " Enter admin login:", echo: false
  9. 1 password = ask "\n Enter admin password:", echo: false
  10. 1 identity = Cipher.generate login, password
  11. 1 display identity
  12. end
  13. 1 private
  14. 1 def display identity
  15. 1 puts "\n\nHere are your credentials:\n"
  16. 1 say <<~MESSAGE.gsub(/^/, " "), :green
  17. AUTHER_SECRET=#{identity.fetch :secret}
  18. AUTHER_ADMIN_LOGIN=#{identity.fetch :login}
  19. AUTHER_ADMIN_PASSWORD=#{identity.fetch :password}
  20. MESSAGE
  21. 1 say "\nReminder: Do not add these credentials to source control.", :yellow
  22. end
  23. end
  24. end

lib/generators/auther/install/install_generator.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module Auther
  3. # Install generator for adding Auther support to existing application.
  4. 1 class InstallGenerator < ::Rails::Generators::Base
  5. 1 source_root File.join(File.dirname(__FILE__), "..", "templates")
  6. 1 desc "Installs Auther settings and routes."
  7. 1 def install
  8. 2 install_initializer
  9. 2 add_routes
  10. end
  11. 1 private
  12. 1 def install_initializer
  13. 2 template File.join("config", "initializers", "auther.rb"),
  14. File.join("config", "initializers", "auther.rb")
  15. end
  16. 1 def add_routes
  17. 2 route %(delete "/logout", to: "auther/session#destroy", as: "logout")
  18. 2 route %(get "/login", to: "auther/session#new", as: "login")
  19. 2 route %(mount Auther::Engine => "/auther")
  20. end
  21. end
  22. end

lib/generators/auther/templates/config/initializers/auther.rb

100.0% lines covered

100.0% branches covered

1 relevant lines. 1 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. 1 # frozen_string_literal: true
  2. Rails.application.config.auther = {
  3. accounts: [
  4. {
  5. name: "admin",
  6. encrypted_login: ENV.fetch("AUTHER_ADMIN_LOGIN"),
  7. encrypted_password: ENV.fetch("AUTHER_ADMIN_PASSWORD"),
  8. paths: ["/admin"]
  9. }
  10. ],
  11. secret: ENV.fetch("AUTHER_SECRET")
  12. }