registration_generator 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd28b26f3f15209f5ae09b58445af142d718a72448469b87b92fc5821c6c4fcd
4
+ data.tar.gz: 15d8d57286ac36cee35843e5ae68911a2027463f37781a6528f52ce6e1f68bb1
5
+ SHA512:
6
+ metadata.gz: daad25001fe12feed81e20fe62cd83b677b8792466f42a4377a62acaf2c50d807e3c384555fb3249b7bf9a5378822958f3bdde7a855415827a75e84405e588fe
7
+ data.tar.gz: 9c139a62bd8c2cb4821e4330cb7cc05c7591a7cc052021ab97ef732300b1736cbdf311e3906480eca7298590cef45dbde38fa3ccd508e064c193f4f80583e48e
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # RegistrationGenerator
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/registration_generator`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/registration_generator.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ Description:
2
+ Creates registration pages for the authentication generator
3
+
4
+ Example:
5
+ bin/rails generate registration
6
+
7
+ This will create:
8
+ regisistration routes
9
+ new registration view
10
+ registrations controller
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "registration_generator"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Your Name"]
5
+ spec.email = ["your_email@example.com"]
6
+
7
+ spec.summary = "A Rails generator for user registration"
8
+ spec.description = "This gem provides a Rails generator to create a registration form and related files."
9
+ spec.homepage = "https://github.com/your_username/registration_generator"
10
+ spec.license = "MIT"
11
+
12
+ spec.files = Dir["{lib}/**/*", "README.md"]
13
+ spec.require_paths = ["lib"]
14
+
15
+ spec.add_dependency "rails", ">= 6.0"
16
+ end
@@ -0,0 +1,25 @@
1
+ # lib/registration_generator/generators/registration/registration_generator.rb
2
+ require "rails/generators"
3
+ require "registration_generator/generators/registration/registration_generator"
4
+
5
+ module RegistrationGenerator
6
+ class RegistrationGenerator < Rails::Generators::Base
7
+ source_root File.expand_path("templates", __dir__)
8
+
9
+ def create_view
10
+ template 'registration_form.html.erb', "app/views/registrations/new.html.erb"
11
+ end
12
+
13
+ def create_sign_in
14
+ template 'sign_in_form.html.erb', "app/views/sessions/new.html.erb", force: true
15
+ end
16
+
17
+ def create_controller
18
+ template 'registrations_controller.rb', "app/controllers/registrations_controller.rb"
19
+ end
20
+
21
+ def add_routes
22
+ route "resource :registration, only: [:new, :create]"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ <h1>Registration</h1>
2
+
3
+ <%%= form_with model: @user, url: registration_path do |f| %>
4
+ <%% if @user.errors.any? %>
5
+ <div>
6
+ <%%= @user.errors.full_messages.to_sentence %>
7
+ </div>
8
+ <%% end %>
9
+
10
+ <div>
11
+ <%%= f.label :email_address %>
12
+ <%%= f.email_field :email_address %>
13
+ </div>
14
+
15
+ <div>
16
+ <%%= f.label :password %>
17
+ <%%= f.password_field :password %>
18
+ </div>
19
+
20
+ <%%= f.submit "Register" %>
21
+ <%% end %>
@@ -0,0 +1,25 @@
1
+ class RegistrationsController < ApplicationController
2
+ allow_unauthenticated_access
3
+
4
+ def new
5
+ redirect_to root_path if authenticated?
6
+ @user = User.new
7
+ end
8
+
9
+ def create
10
+ @user = User.new(user_params)
11
+
12
+ if @user.save
13
+ start_new_session_for @user
14
+ redirect_to root_path, notice: "You have successfully registered!"
15
+ else
16
+ render :new, status: :unprocessable_entity
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def user_params
23
+ params.require(:user).permit(:email_address, :password)
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ <%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
2
+ <%%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %>
3
+
4
+ <%%= form_with url: session_path do |form| %>
5
+ <%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email_address] %><br>
6
+ <%%= form.password_field :password, required: true, autocomplete: "current-password", placeholder: "Enter your password", maxlength: 72 %><br>
7
+ <%%= form.submit "Sign in" %>
8
+ <%% end %>
9
+ <br>
10
+
11
+ <%%= link_to "Forgot password?", new_password_path %> |
12
+ <%%= link_to "Register", new_registration_path %>
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RegistrationGenerator
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "registration_generator/version"
4
+
5
+ module RegistrationGenerator
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: registration_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Your Name
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-02-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '8.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '8.0'
27
+ description: This gem provides a Rails generator to create a registration form and
28
+ related files.
29
+ email:
30
+ - your_email@example.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - README.md
36
+ - lib/registration_generator.rb
37
+ - lib/registration_generator/USAGE
38
+ - lib/registration_generator/registration_generator.gemspec
39
+ - lib/registration_generator/registration_generator.rb
40
+ - lib/registration_generator/templates/registration_form.html.erb
41
+ - lib/registration_generator/templates/registrations_controller.rb
42
+ - lib/registration_generator/templates/sign_in_form.html.erb
43
+ - lib/registration_generator/version.rb
44
+ homepage: https://github.com/your_username/registration_generator
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubygems_version: 3.5.11
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: A Rails generator for user registration
67
+ test_files: []