dangerzone 0.0.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.
Files changed (28) hide show
  1. data/README.md +151 -0
  2. data/dangerzone.gemspec +18 -0
  3. data/lib/.DS_Store +0 -0
  4. data/lib/dangerzone/.DS_Store +0 -0
  5. data/lib/dangerzone/dangerzone_generator.rb +122 -0
  6. data/lib/dangerzone/templates/.DS_Store +0 -0
  7. data/lib/dangerzone/templates/controllers/application_controller.rb +11 -0
  8. data/lib/dangerzone/templates/controllers/create_accounts_controller.rb +42 -0
  9. data/lib/dangerzone/templates/controllers/reset_passwords_controller.rb +43 -0
  10. data/lib/dangerzone/templates/controllers/sessions_controller.rb +30 -0
  11. data/lib/dangerzone/templates/mailers/dangerzone_mailer.rb +14 -0
  12. data/lib/dangerzone/templates/migration.rb +24 -0
  13. data/lib/dangerzone/templates/models/user.rb +25 -0
  14. data/lib/dangerzone/templates/routes.rb +18 -0
  15. data/lib/dangerzone/templates/views/.DS_Store +0 -0
  16. data/lib/dangerzone/templates/views/create_accounts/check_your_email.html.erb +11 -0
  17. data/lib/dangerzone/templates/views/create_accounts/dangerzone.html.erb +20 -0
  18. data/lib/dangerzone/templates/views/create_accounts/new.html.erb +11 -0
  19. data/lib/dangerzone/templates/views/dangerzone_mailer/account_confirmation_email.html.erb +5 -0
  20. data/lib/dangerzone/templates/views/dangerzone_mailer/account_confirmation_email.text.erb +6 -0
  21. data/lib/dangerzone/templates/views/dangerzone_mailer/reset_password_email.html.erb +5 -0
  22. data/lib/dangerzone/templates/views/dangerzone_mailer/reset_password_email.text.erb +5 -0
  23. data/lib/dangerzone/templates/views/nav.html.erb +10 -0
  24. data/lib/dangerzone/templates/views/reset_passwords/new.html.erb +10 -0
  25. data/lib/dangerzone/templates/views/reset_passwords/reset_password_form.html.erb +10 -0
  26. data/lib/dangerzone/templates/views/sessions/new.html.erb +12 -0
  27. data/lib/dangerzone.rb +1 -0
  28. metadata +122 -0
data/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # Dangerzone
2
+
3
+ ## About
4
+ Dangerzone handles sign-in, sign-out, creating new accounts, confirmation emails, reset password emails,
5
+ and user authentification stuff that pretty much every web app needs.
6
+
7
+ It's pretty much a really stripped down Devise. While Devise is designed for people with a lot of experience,
8
+ Dangerzone is more for beginners. All of the files it generates and logic it appends are easy to find and
9
+ explore (hopefully, anyway), so if you're new to Rails you can use Dangerzone to learn (also hopefully).
10
+
11
+ It's also for people who maybe have more experience and don't want to spend time writing all of this stuff
12
+ out by hand but don't want to use Devise for whatever reason (ie those with some experience but still
13
+ don't understand Devise)
14
+
15
+ ## Dependencies
16
+ You'll need these gems (and the gems that they depend on) to use Dangerzone:
17
+
18
+ * Rails 3.2
19
+ * Bcrypt-ruby 3.0
20
+ * Thor
21
+
22
+ ## How to install
23
+ You can do one of these in your command line (if you have the RubyGems command line stuff installed):
24
+
25
+ ```ruby
26
+ gem install dangerzone
27
+ ```
28
+
29
+ Alternatively, you can just add this to your app's GemFile:
30
+
31
+ ```ruby
32
+ gem 'dangerzone'
33
+ ```
34
+
35
+ And then bundle or bundle install.
36
+
37
+ ## How to use
38
+
39
+ First, add this to your Gemfile:
40
+
41
+ ```ruby
42
+ gem 'dangerzone'
43
+ ```
44
+
45
+ Then bundle or bundle install.
46
+
47
+ Then run this command from your app's root directory:
48
+
49
+ ```ruby
50
+ rails generate dangerzone
51
+ ```
52
+
53
+ You can also put '```g```'' instead of '```generate```' if you're really in a hurry. Anyway, you should see something that
54
+ looks like this:
55
+
56
+ ```ruby
57
+ remove public/index.html
58
+ create app/views/layouts/_dangerzone_nav.html.erb
59
+ create app/models/user.rb
60
+ create app/controllers/create_accounts_controller.rb
61
+ create app/controllers/reset_passwords_controller.rb
62
+ create app/controllers/sessions_controller.rb
63
+ create app/mailers/dangerzone_mailer.rb
64
+ create app/views/create_accounts
65
+ [etc...]
66
+ ```
67
+
68
+ Now, if you're in a fresh app, all you really have to do is ```rake db:migrate```
69
+
70
+ Note: If you're adding Dangerzone to an existing app then things can be a bit more tricky. For instance,
71
+ if you've changed your code in certain places Dangerzone may not edit the files correctly. It may
72
+ also overwrite some existing files if they have the same as the files Dangerzone tries to create.
73
+ Check out the 'Things to keep in mind' section below for more information.
74
+
75
+ Once you've added some pages you only want registered users to see (ie a my account page), all you have to do
76
+ is add this to the controllers that you only want registered/authorized users to see:
77
+
78
+ ```ruby
79
+ before_filter :authorize_user
80
+ ```
81
+
82
+ That's it. Well if you only want specific actions on a given controller to be for registered users only, just use:
83
+
84
+ ```ruby
85
+ before_filter :authorize_user, :only => [ :different, :controller, :actions ]
86
+ ```
87
+
88
+ or
89
+
90
+ ```ruby
91
+ before_filter :authorize_user, :except => [ :various, :controller, :actions ]
92
+ ```
93
+
94
+ Now that's it.
95
+
96
+ ## Things to keep in mind
97
+
98
+ * Dangerzone generates a migration file that creates a users table, so if you already have a users table
99
+ or call your users something else, then you'll have to write your own migration that adds the appropriate
100
+ columns and default values to your model.
101
+ * If you already have a user.rb file in your models it may be overwritten. Check the list below for all of the
102
+ files Dangerzone generates and my overwrite.
103
+ * Dangerzone edits certain files (for instance, it uncomments bcrypt in your GemFile), so if you've changed
104
+ some code in those files in a certain way, Dagerzone may not edit them properly. Consult the list below
105
+ for all of the files it edits and how it edits them.
106
+ * Dangerzone sets a root\_url that you'll probably want to change.
107
+ * Dangerzone uses action mailer and sets action mailer's default to 'localhost:3000' in your development.rb file.
108
+ So if you want to use a different mailer or use Dangerzone in test or production environments, you'll have to figure
109
+ out how to configure it for those situations yourself.
110
+ * Dangerzone gives you a current\_user method that you can call in any of your controllers. It returns @current\_user
111
+ in addition to setting the @current\_user instance variable. The instance variable will already be set for any action
112
+ has authorize\_user run in the before filter.
113
+ * Dangerzone deletes index.html from your app's public folder.
114
+ * The pages and emails that Dangerzone generates for you are pretty bare bones, so you'll probably want to style them
115
+ * If you actually use Dangerzone code in production, remember that the email address validation is basic so
116
+ every once in a while you should probably destroy all of the accounts that are reasonably old and are unconfirmed.
117
+ Or set up an automated task that does that.
118
+
119
+ ### Files Dangerzone Edits
120
+ * app/controllers/application\_controller.rb - adds authorize\_user and current\_user methods (so every controller
121
+ can add them to before\_filters)
122
+ * app/view/layouts/application.html.erb - adds render
123
+ * config/environments/development.rb - sets action mailer's default url to localhost:3000
124
+ * config/routes.rb - adds routes and sets root\_url
125
+ * GemFile - uncomments bcrypt
126
+
127
+ ### Directories Dangerzone Creates
128
+ * app/mailers/dangerzone\_mailer.rb
129
+ * app/views/create\_accounts
130
+ * app/views/dangerzone\_mailer
131
+ * app/views/reset\_passwords
132
+ * app/views/sessions
133
+
134
+ ### Files Dangerzone Creates
135
+ * app/views/layouts/\_dangerzone_nav.html.erb
136
+ * app/models/user.rb
137
+ * app/controllers/create\_accounts\_controller.rb
138
+ * app/controllers/reset\_passwords\_controller.rb
139
+ * app/controllers/sessions\_controller.rb
140
+ * app/views/create\_accounts/check\_your\_email.html.erb
141
+ * app/views/create\_accounts/new.html.erb
142
+ * app/views/create\_accounts/dangerzone.html.erb
143
+ * app/views/dangerzone\_mailer/account\_confirmation\_email.html.erb
144
+ * app/views/dangerzone\_mailer/account\_confirmation\_email.text.erb
145
+ * app/views/dangerzone\_mailer/reset\_password\_email.html.erb
146
+ * app/views/dangerzone\_mailer/reset\_password\_email.text.erb
147
+ * app/views/layouts/\_dangerzone\_nav.html.erb
148
+ * app/views/reset\_passwords/new.html.erb
149
+ * app/views/reset\_passwords/reset\_password\_form.html.erb
150
+ * app/views/sessions/new.html.erb
151
+ * db/migrate/[some timestamp]\_create\_users\_table\_via\_dangerzone.rb
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "dangerzone"
3
+ s.version = '0.0.0'
4
+ s.date = '2013-03-30'
5
+ s.license = "MIT"
6
+ s.summary = "Takes care of creating accounts, login, logout, forgot password, etc. in Rails"
7
+ s.email = "michael.crismali@gmail.com"
8
+ s.homepage = "https://github.com/michaelcrismali/dangerzone"
9
+ s.authors = ['Michael Crismali']
10
+ s.description = "Generates a sign-in, sign-out, create account, forgot password, account confirmation systems for Rails apps. It's Devise for beginners."
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.require_paths = ["lib"]
14
+
15
+ s.add_dependency("bcrypt-ruby", "~> 3.0")
16
+ s.add_dependency("rails", "~> 3.2")
17
+ s.add_dependency("thor")
18
+ end
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,122 @@
1
+ require 'rails/generators'
2
+ class DangerzoneGenerator < Rails::Generators::Base
3
+
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def edit_the_routes_file
7
+ routes = IO.read(get_directory + '/templates/routes.rb')
8
+ line = "::Application.routes.draw do"
9
+ gsub_file 'config/routes.rb', /.+(#{Regexp.escape(line)})/mi do |match|
10
+ "#{match}\n\n#{routes}\n"
11
+ end
12
+ end
13
+
14
+ def get_rid_of_rails_default_index_page_in_index
15
+ remove_file "public/index.html"
16
+ end
17
+
18
+ def generate_the_nav_partial
19
+ copy_file "views/nav.html.erb", "app/views/layouts/_dangerzone_nav.html.erb"
20
+ end
21
+
22
+ def add_nav_partial_and_notice_to_application_html_erb
23
+ nav = "<%= render 'layouts/dangerzone_nav' %>\n\n<%= notice %>"
24
+ line = "<body>"
25
+ gsub_file 'app/views/layouts/application.html.erb', /(#{Regexp.escape(line)})/mi do |match|
26
+ "#{match}\n#{nav}\n"
27
+ end
28
+ end
29
+
30
+ def generate_user_model_file
31
+ copy_file "models/user.rb", "app/models/user.rb"
32
+ end
33
+
34
+ def generate_the_controllers
35
+ copy_file "controllers/create_accounts_controller.rb", "app/controllers/create_accounts_controller.rb"
36
+ copy_file "controllers/reset_passwords_controller.rb", "app/controllers/reset_passwords_controller.rb"
37
+ copy_file "controllers/sessions_controller.rb", "app/controllers/sessions_controller.rb"
38
+ end
39
+
40
+ def add_methods_to_application_controller
41
+ app_controller_methods = IO.read(get_directory + '/templates/controllers/application_controller.rb')
42
+ line = "protect_from_forgery"
43
+ gsub_file 'app/controllers/application_controller.rb', /.+(#{Regexp.escape(line)})/mi do |match|
44
+ "#{match}\n\n#{app_controller_methods}\n"
45
+ end
46
+ end
47
+
48
+ def generate_mailer
49
+ copy_file "mailers/dangerzone_mailer.rb", "app/mailers/dangerzone_mailer.rb"
50
+ end
51
+
52
+ def add_mailer_config_to_development
53
+ comment = "# Via dangerzone: configures actionmailer to use localhost:3000 as its default url"
54
+ config_stuff = "config.action_mailer.default_url_options = { :host => 'localhost:3000' }"
55
+ line = "config.assets.debug = true"
56
+ gsub_file 'config/environments/development.rb', /.+(#{Regexp.escape(line)})/mi do |match|
57
+ "#{match}\n\n #{comment}\n #{config_stuff}\n\n"
58
+ end
59
+ end
60
+
61
+ def uncomment_bcrypt_in_gemfile
62
+ uncommented = "gem 'bcrypt-ruby'"
63
+ line = "# gem 'bcrypt-ruby'"
64
+ gsub_file 'Gemfile', /(#{Regexp.escape(line)})/mi do |match|
65
+ "#{uncommented}"
66
+ end
67
+ end
68
+
69
+ def generate_view_directories
70
+ empty_directory "app/views/create_accounts"
71
+ empty_directory "app/views/dangerzone_mailer"
72
+ empty_directory "app/views/reset_passwords"
73
+ empty_directory "app/views/sessions"
74
+ end
75
+
76
+ def fill_view_directories
77
+ copy_file "views/create_accounts/check_your_email.html.erb", "app/views/create_accounts/check_your_email.html.erb"
78
+ copy_file "views/create_accounts/new.html.erb", "app/views/create_accounts/new.html.erb"
79
+ copy_file "views/create_accounts/dangerzone.html.erb", "app/views/create_accounts/dangerzone.html.erb"
80
+
81
+ copy_file "views/dangerzone_mailer/account_confirmation_email.html.erb", "app/views/dangerzone_mailer/account_confirmation_email.html.erb"
82
+ copy_file "views/dangerzone_mailer/account_confirmation_email.text.erb", "app/views/dangerzone_mailer/account_confirmation_email.text.erb"
83
+ copy_file "views/dangerzone_mailer/reset_password_email.html.erb", "app/views/dangerzone_mailer/reset_password_email.html.erb"
84
+ copy_file "views/dangerzone_mailer/reset_password_email.text.erb", "app/views/dangerzone_mailer/reset_password_email.text.erb"
85
+
86
+ copy_file "views/reset_passwords/new.html.erb", "app/views/reset_passwords/new.html.erb"
87
+ copy_file "views/reset_passwords/reset_password_form.html.erb", "app/views/reset_passwords/reset_password_form.html.erb"
88
+
89
+ copy_file "views/sessions/new.html.erb", "app/views/sessions/new.html.erb"
90
+ end
91
+
92
+ include Rails::Generators::Migration
93
+ desc "add the migrations"
94
+
95
+ def self.next_migration_number(path)
96
+ unless @prev_migration_nr
97
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
98
+ else
99
+ @prev_migration_nr += 1
100
+ end
101
+ @prev_migration_nr.to_s
102
+ end
103
+
104
+ def generate_the_users_migration_file
105
+ migration_template "migration.rb", "db/migrate/create_users_table_via_dangerzone.rb"
106
+ end
107
+
108
+ private
109
+
110
+ def gsub_file(relative_destination, regexp, *args, &block)
111
+ path = relative_destination
112
+ content = File.read(path).gsub(regexp, *args, &block)
113
+ File.open(path, 'wb') { |file| file.write(content) }
114
+ end
115
+
116
+ def get_directory
117
+ directory = __FILE__.split('/')
118
+ directory.pop
119
+ directory.join('/')
120
+ end
121
+
122
+ end
Binary file
@@ -0,0 +1,11 @@
1
+ def current_user
2
+ @current_user = User.find_by_remember_token(cookies[:remember_token])
3
+ @current_user ||= User.find_by_id(session[:user_id])
4
+ @current_user = nil if @current_user && request.remote_ip != @current_user.sign_in_ip
5
+ @current_user
6
+ end
7
+
8
+ def authorize_user
9
+ redirect_to sign_in_url if current_user.nil?
10
+ end
11
+
@@ -0,0 +1,42 @@
1
+ class CreateAccountsController < ApplicationController
2
+
3
+ def create
4
+ session[:email] = params[:user][:email]
5
+ @user = User.new(params[:user])
6
+ @user.email = @user.email.downcase
7
+ @user.remember_token = SecureRandom.urlsafe_base64
8
+ if @user.update_reset_password_credentials
9
+ DangerzoneMailer.account_confirmation_email(@user).deliver
10
+ redirect_to check_your_email_url, notice: "Registration successful."
11
+ else
12
+ redirect_to sign_up_url, notice: "Registration unsuccessful"
13
+ end
14
+ end
15
+
16
+ def resend_confirmation_email
17
+ @user = User.find_by_email(params[:email].downcase)
18
+ if @user && !@user.confirmed
19
+ @user.update_reset_password_credentials
20
+ DangerzoneMailer.account_confirmation_email(@user).deliver
21
+ redirect_to check_your_email_url, notice: "Resent confirmation email."
22
+ else
23
+ redirect_to check_your_email_url, notice: "Something went wrong."
24
+ end
25
+ end
26
+
27
+ def confirm
28
+ @user = User.find_by_id(params[:id])
29
+ if @user && (Time.now - @user.reset_password_sent_at) < 60.minutes && @user.reset_password_token == params[:reset_password_token]
30
+ reset_session
31
+ @user.confirm(request.remote_ip)
32
+ session[:user_id] = @user.id
33
+ redirect_to root_url, notice: "User confirmation successful."
34
+ else
35
+ redirect_to sign_up_url, notice: "User confirmation unsuccessful."
36
+ end
37
+ end
38
+
39
+ def new
40
+ end
41
+
42
+ end
@@ -0,0 +1,43 @@
1
+ class ResetPasswordsController < ApplicationController
2
+
3
+ def send_reset_password
4
+ @user = User.find_by_email(params[:email].downcase)
5
+ if @user.update_reset_password_credentials
6
+ DangerzoneMailer.reset_password_email(@user).deliver
7
+ redirect_to forgot_password_url, notice: "Reset password email successfully sent."
8
+ else
9
+ redirect_to forgot_password_url, notice: "Reset password email failed to send."
10
+ end
11
+ end
12
+
13
+ def reset_password_form
14
+ @user = User.find_by_id(params[:id])
15
+ if @user && (Time.now - @user.reset_password_sent_at) < 60.minutes && @user.reset_password_token == params[:reset_password_token]
16
+ session[:reset_password_user_id] = @user.id
17
+ else
18
+ redirect_to forgot_password_url, notice: "There was a problem, try having the email resent to you."
19
+ end
20
+ end
21
+
22
+ def update_password
23
+ @user = User.find_by_id(session[:reset_password_user_id])
24
+ if @user && (Time.now - @user.reset_password_sent_at) < 60.minutes
25
+ @user.password = params[:password]
26
+ @user.password_confirmation = params[:password_confirmation]
27
+ @user.reset_password_token = SecureRandom.urlsafe_base64
28
+ if @user.save
29
+ reset_session
30
+ session[:user_id] = @user.id
31
+ redirect_to root_url, notice: "Password successfully updated."
32
+ else
33
+ redirect_to send_reset_password_url, notice: "Update password unsuccessful."
34
+ end
35
+ else
36
+ redirect_to send_reset_password_url, notice: "Update password unsuccessful."
37
+ end
38
+ end
39
+
40
+ def new
41
+ end
42
+
43
+ end
@@ -0,0 +1,30 @@
1
+ class SessionsController < ApplicationController
2
+
3
+ def create
4
+ @user = User.find_by_email(params[:email].downcase)
5
+ if @user && @user.authenticate(params[:password]) && @user.confirmed
6
+ @user.sign_in_ip = request.remote_ip
7
+ @user.sign_in_count = @user.sign_in_count + 1
8
+ if params[:remember_me] == '1'
9
+ @user.remember_token = SecureRandom.urlsafe_base64
10
+ cookies.permanent[:remember_token] = @user.remember_token
11
+ else
12
+ session[:user_id] = @user.id
13
+ end
14
+ @user.save
15
+ redirect_to root_url, :notice => "Sign-in successful."
16
+ else
17
+ redirect_to sign_in_url, :notice => "Sign-in unsuccessful."
18
+ end
19
+ end
20
+
21
+ def destroy
22
+ cookies.delete(:remember_token)
23
+ reset_session
24
+ redirect_to sign_in_url, :notice => "Sign-out successful."
25
+ end
26
+
27
+ def new
28
+ end
29
+
30
+ end
@@ -0,0 +1,14 @@
1
+ class DangerzoneMailer < ActionMailer::Base
2
+ default from: "YOUR SITE"
3
+
4
+ def account_confirmation_email(user)
5
+ @user = user
6
+ mail to: @user.email, subject: "Confirm your account"
7
+ end
8
+
9
+ def reset_password_email(user)
10
+ @user = user
11
+ mail to: @user.email, subject: "Reset your password"
12
+ end
13
+
14
+ end
@@ -0,0 +1,24 @@
1
+ class CreateUsersTableViaDangerzone < ActiveRecord::Migration
2
+
3
+ def up
4
+ create_table :users do |t|
5
+ t.string :email
6
+ t.string :password
7
+ t.string :password_confirmation
8
+ t.string :password_digest
9
+ t.string :sign_in_ip
10
+ t.string :remember_token
11
+ t.string :reset_password_token
12
+ t.datetime :reset_password_sent_at
13
+ t.boolean :confirmed, :default => false
14
+ t.integer :sign_in_count, :default => 1
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+
20
+ def down
21
+ drop_table :users
22
+ end
23
+
24
+ end
@@ -0,0 +1,25 @@
1
+ class User < ActiveRecord::Base
2
+
3
+ has_secure_password
4
+
5
+ attr_accessible :email, :password, :password_confirmation
6
+
7
+ validates_presence_of :email
8
+ validates_uniqueness_of :email
9
+ validates_format_of :email, :with => /.+@.+\..+/i
10
+
11
+ def update_reset_password_credentials
12
+ self.reset_password_sent_at = Time.now
13
+ self.reset_password_token = SecureRandom.urlsafe_base64
14
+ self.save
15
+ end
16
+
17
+ def confirm(request_remote_ip)
18
+ self.confirmed = true
19
+ self.reset_password_sent_at = nil
20
+ self.reset_password_token = nil
21
+ self.sign_in_ip = request_remote_ip
22
+ self.save
23
+ end
24
+
25
+ end
@@ -0,0 +1,18 @@
1
+ root to: 'create_accounts#dangerzone'
2
+
3
+ get '/dangerzone' => 'create_accounts#dangerzone', as: 'dangerzone'
4
+
5
+ post '/sessions' => 'sessions#create', as: 'sessions'
6
+ get '/sign-in' => 'sessions#new', as: 'sign_in'
7
+ delete '/sign-out' => 'sessions#destroy', as: 'sign_out'
8
+
9
+ post '/create_accounts' => 'create_accounts#create', as: 'create_accounts'
10
+ get '/sign-up' => 'create_accounts#new', as: 'sign_up'
11
+ get '/sign-up/:id/:reset_password_token' => 'create_accounts#confirm', as: 'confirm'
12
+ get '/check_your_email' => 'create_accounts#check_your_email', as: 'check_your_email'
13
+ put '/resend_confirmation_email' => 'create_accounts#resend_confirmation_email', as: 'resend_confirmation_email'
14
+
15
+ get '/forgot_password' => 'reset_passwords#new', as: 'forgot_password'
16
+ put '/reset_password' => 'reset_passwords#send_reset_password', as: 'send_reset_password'
17
+ get '/reset_password/:id/:reset_password_token' => 'reset_passwords#reset_password_form', as: 'reset_password_form'
18
+ put '/update_password' => 'reset_passwords#update_password', as: 'update_password'
@@ -0,0 +1,11 @@
1
+ <div>
2
+ Check your inbox for a confirmation email.
3
+ <br />
4
+ (Didn't get one? Enter your email address and we'll send you a fresh one.)
5
+ <br />
6
+ <%= form_tag(resend_confirmation_email_url, method: 'put') do %>
7
+ <%= label_tag :email %>
8
+ <%= email_field_tag :email, nil, placeholder: 'Email' %>
9
+ <%= submit_tag 'Resend Email' %>
10
+ <% end -%>
11
+ </div>
@@ -0,0 +1,20 @@
1
+ <h5>Lana.... Lana.... LANA!!!</h5>
2
+
3
+ <h3>Dangerzone!</h3>
4
+
5
+ <p>This page is just a placeholder until you set up your root_url, so...</p>
6
+
7
+ <ul>
8
+ <li>In your /config/routes.rb change the root_url to a different controller#action
9
+ (or get rid of the 'root to:' altogether and change the controllers dangerzone
10
+ generated for you so you don't get a NoMethodError). While you're there
11
+ also get rid of the "/dangerzone" route.</li>
12
+ <li>Once you've done that, delete this page
13
+ (it's in app/views/create_accounts as dangerzone.html.erb),
14
+ unless you want to hold on to it for nostalgia's sake.</li>
15
+ <li>Don't forget to add 'before_filter :authorize_user'
16
+ to the controllers that have actions you only want registered
17
+ users to be able to use. </li>
18
+ <li>For more help or information regarding dangerzone, check out the dangerzone
19
+ readme on <%= link_to 'Github', 'https://github.com/michaelcrismali/dangerzone' %></li>
20
+ </ul>
@@ -0,0 +1,11 @@
1
+ <div>
2
+ <%= form_for(User.new, :url => create_accounts_url, :method => :post) do |f| %>
3
+ <%= label_tag :email %>
4
+ <%= f.email_field :email, :placeholder => "Email", value: session[:email] %>
5
+ <%= label_tag :password %>
6
+ <%= f.password_field :password, :placeholder => "Password" %>
7
+ <%= label_tag :password_confirmation %>
8
+ <%= f.password_field :password_confirmation, :placeholder => "Confirm Password" %>
9
+ <%= f.submit "Sign Up" %>
10
+ <% end %>
11
+ </div>
@@ -0,0 +1,5 @@
1
+ Hey!
2
+
3
+ Confirm your account by clicking the link below:
4
+
5
+ <%= link_to "Click here to confirm your account", confirm_url(@user.id, @user.reset_password_token) %>
@@ -0,0 +1,6 @@
1
+ Hey!
2
+
3
+ Confirm your account by clicking the link below:
4
+
5
+ <%= confirm_url(@user.id, @user.reset_password_token) %>
6
+
@@ -0,0 +1,5 @@
1
+ Hey!
2
+
3
+ Reset your password by clicking the link below:
4
+
5
+ <%= link_to "Click me to reset your password!", reset_password_form_url(@user.id, @user.reset_password_token) %>
@@ -0,0 +1,5 @@
1
+ Hey!
2
+
3
+ Reset your password by clicking the link below:
4
+
5
+ <%= reset_password_form_url(@user.id, @user.reset_password_token) %>
@@ -0,0 +1,10 @@
1
+ <% if @current_user.present? %>
2
+ <nav>
3
+ <%= link_to "Sign-out", sign_out_url, :method => 'delete' %>
4
+ </nav>
5
+ <% else %>
6
+ <nav>
7
+ <%= link_to "Sign up", sign_up_url %>
8
+ <%= link_to "Sign in", sign_in_url %>
9
+ </nav>
10
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <div>
2
+ <h3>Forgot your password? Just enter your email address below and click submit for an
3
+ email that will help you reset your password.</h3>
4
+ <br />
5
+ <%= form_tag(send_reset_password_url, method: 'put') do %>
6
+ <%= label_tag :email %>
7
+ <%= email_field_tag :email, nil, placeholder: 'Email' %>
8
+ <%= submit_tag 'Submit' %>
9
+ <% end -%>
10
+ </div>
@@ -0,0 +1,10 @@
1
+ <h1>Reset your password below:</h1>
2
+ <div>
3
+ <%= form_tag( update_password_url, method: 'put') do %>
4
+ <%= label_tag :password %>
5
+ <%= password_field_tag :password, nil, placeholder: 'Password' %>
6
+ <%= label_tag :password_confirmation %>
7
+ <%= password_field_tag :password_confirmation, nil, placeholder: 'Password Confirmation' %>
8
+ <%= submit_tag 'Update' %>
9
+ <% end -%>
10
+ </div>
@@ -0,0 +1,12 @@
1
+ <div>
2
+ <%= form_tag(sessions_url, :method => :post) do %>
3
+ <%= label_tag :email %>
4
+ <%= email_field_tag :email, nil, :placeholder => "Email" %>
5
+ <%= label_tag :password %>
6
+ <%= password_field_tag :password, nil, :placeholder => "Password" %>
7
+ <%= label_tag :remember_me %>
8
+ <%= check_box_tag :remember_me %>
9
+ <%= submit_tag "Sign in" %>
10
+ <% end %>
11
+ <%= link_to 'Forgot password?', forgot_password_url %>
12
+ </div>
data/lib/dangerzone.rb ADDED
@@ -0,0 +1 @@
1
+ require 'dangerzone/dangerzone_generator'
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dangerzone
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Crismali
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bcrypt-ruby
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.2'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: thor
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Generates a sign-in, sign-out, create account, forgot password, account
63
+ confirmation systems for Rails apps. It's Devise for beginners.
64
+ email: michael.crismali@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - README.md
70
+ - dangerzone.gemspec
71
+ - lib/.DS_Store
72
+ - lib/dangerzone.rb
73
+ - lib/dangerzone/.DS_Store
74
+ - lib/dangerzone/dangerzone_generator.rb
75
+ - lib/dangerzone/templates/.DS_Store
76
+ - lib/dangerzone/templates/controllers/application_controller.rb
77
+ - lib/dangerzone/templates/controllers/create_accounts_controller.rb
78
+ - lib/dangerzone/templates/controllers/reset_passwords_controller.rb
79
+ - lib/dangerzone/templates/controllers/sessions_controller.rb
80
+ - lib/dangerzone/templates/mailers/dangerzone_mailer.rb
81
+ - lib/dangerzone/templates/migration.rb
82
+ - lib/dangerzone/templates/models/user.rb
83
+ - lib/dangerzone/templates/routes.rb
84
+ - lib/dangerzone/templates/views/.DS_Store
85
+ - lib/dangerzone/templates/views/create_accounts/check_your_email.html.erb
86
+ - lib/dangerzone/templates/views/create_accounts/dangerzone.html.erb
87
+ - lib/dangerzone/templates/views/create_accounts/new.html.erb
88
+ - lib/dangerzone/templates/views/dangerzone_mailer/account_confirmation_email.html.erb
89
+ - lib/dangerzone/templates/views/dangerzone_mailer/account_confirmation_email.text.erb
90
+ - lib/dangerzone/templates/views/dangerzone_mailer/reset_password_email.html.erb
91
+ - lib/dangerzone/templates/views/dangerzone_mailer/reset_password_email.text.erb
92
+ - lib/dangerzone/templates/views/nav.html.erb
93
+ - lib/dangerzone/templates/views/reset_passwords/new.html.erb
94
+ - lib/dangerzone/templates/views/reset_passwords/reset_password_form.html.erb
95
+ - lib/dangerzone/templates/views/sessions/new.html.erb
96
+ homepage: https://github.com/michaelcrismali/dangerzone
97
+ licenses:
98
+ - MIT
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 1.8.24
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: Takes care of creating accounts, login, logout, forgot password, etc. in
121
+ Rails
122
+ test_files: []