bootup 0.0.2 → 0.0.3
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.
- data/README.md +35 -10
- data/lib/bootup/version.rb +1 -1
- data/lib/generators/bootup/bootup_generator.rb +81 -21
- data/lib/generators/bootup/templates/.gitignore +25 -0
- data/lib/generators/bootup/templates/authentication/controllers/application_controller.rb +9 -0
- data/lib/generators/bootup/templates/authentication/controllers/pages_controller.rb +6 -0
- data/lib/generators/bootup/templates/authentication/controllers/user_sessions_controller.rb.erb +25 -0
- data/lib/generators/bootup/templates/authentication/controllers/users_controller.rb.erb +81 -0
- data/lib/generators/bootup/templates/authentication/migrate/20121128071307_sorcery_core.rb +16 -0
- data/lib/generators/bootup/templates/authentication/models/.gitkeep +0 -0
- data/lib/generators/bootup/templates/authentication/models/sorcery_core.rb.erb +16 -0
- data/lib/generators/bootup/templates/authentication/models/user_mongoid.rb.erb +15 -0
- data/lib/generators/bootup/templates/authentication/models/user_others.rb.erb +7 -0
- data/lib/generators/bootup/templates/authentication/routes.rb.erb +11 -0
- data/lib/generators/bootup/templates/authentication/sorcery.rb +398 -0
- data/lib/generators/bootup/templates/authentication/views/layouts/application.html.erb +79 -0
- data/lib/generators/bootup/templates/authentication/views/pages/home.html.erb +2 -0
- data/lib/generators/bootup/templates/authentication/views/user_sessions/_form.html.erb +12 -0
- data/lib/generators/bootup/templates/authentication/views/user_sessions/create.html.erb +2 -0
- data/lib/generators/bootup/templates/authentication/views/user_sessions/destroy.html.erb +2 -0
- data/lib/generators/bootup/templates/authentication/views/user_sessions/new.html.erb +5 -0
- data/lib/generators/bootup/templates/authentication/views/users/_form.html.erb +15 -0
- data/lib/generators/bootup/templates/authentication/views/users/edit.html.erb +6 -0
- data/lib/generators/bootup/templates/authentication/views/users/index.html.erb +29 -0
- data/lib/generators/bootup/templates/authentication/views/users/new.html.erb +4 -0
- data/lib/generators/bootup/templates/authentication/views/users/show.html.erb +2 -0
- data/lib/generators/bootup/templates/database.yml.erb +5 -3
- metadata +25 -2
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Bootup
|
2
2
|
|
3
|
-
Provides a rails generator
|
3
|
+
Provides a rails generator which installs a few useful gems & sets up authentication using sorcery along with scaffolding.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -39,16 +39,40 @@ Note: If *APP_NAME* is not supplied, the root folder name would be used as *APP_
|
|
39
39
|
|
40
40
|
The following gems would be installed:
|
41
41
|
|
42
|
-
1. rails
|
43
|
-
2.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
1. rails
|
43
|
+
2. jquery-rails
|
44
|
+
|
45
|
+
Database Stuff:
|
46
|
+
|
47
|
+
1. pg
|
48
|
+
2. mongoid
|
49
|
+
3. sqlite
|
50
|
+
|
51
|
+
Assets (Outside asset group for heroku integration):
|
52
|
+
|
53
|
+
1. twitter-bootstrap-rails (Generator would be run automatically)
|
54
|
+
2. jquery-datatables-rails (Automatically included in application.js & initialized to #datatables)
|
55
|
+
|
56
|
+
View Stuff
|
57
|
+
|
58
|
+
1. simple_form (Generator would be run automatically)
|
59
|
+
|
60
|
+
Authentication:
|
61
|
+
1. sorcery
|
62
|
+
|
63
|
+
Server:
|
64
|
+
1. thin
|
65
|
+
|
66
|
+
Group Assets:
|
67
|
+
|
68
|
+
1. less-rails
|
69
|
+
2. sass-rails
|
70
|
+
3. coffee-rails
|
71
|
+
4. uglifier
|
72
|
+
5. therubyracer
|
50
73
|
|
51
74
|
Group Test:
|
75
|
+
|
52
76
|
1. spork (Pre-configured with my personal preferences for pre-fork & each_run blocks)
|
53
77
|
2. faker
|
54
78
|
3. capybara
|
@@ -57,7 +81,8 @@ Group Test:
|
|
57
81
|
6. database_cleaner
|
58
82
|
|
59
83
|
Group Development & Test:
|
60
|
-
|
84
|
+
|
85
|
+
1. rspec-rails (Generator would be run automatically. Spec file replaced)
|
61
86
|
2. guard-rspec (Initialized. Guard watches views & runs request specs)
|
62
87
|
3. rb-inotify
|
63
88
|
4. libnotify (for Linux)
|
data/lib/bootup/version.rb
CHANGED
@@ -3,72 +3,132 @@ class BootupGenerator < Rails::Generators::Base
|
|
3
3
|
argument :app_name, type: :string, default: Rails.application.class.parent
|
4
4
|
|
5
5
|
def generate_bootup
|
6
|
-
log :
|
6
|
+
log :bootup, "Booting #{app_name}......"
|
7
7
|
|
8
|
-
db = ask("
|
9
|
-
|
8
|
+
db = ask("\n\nWhat database would you like to start off with? P-Postgres / M-Mongoid / Default-SQLite", :blue)
|
9
|
+
case db
|
10
|
+
when "P","p"
|
10
11
|
@db = 'postgres'
|
11
|
-
|
12
|
+
when "M","m"
|
12
13
|
@db = 'mongoid'
|
13
14
|
else
|
14
15
|
@db = 'sqlite'
|
15
16
|
end
|
16
17
|
|
17
|
-
log :
|
18
|
+
log :bootup_log, "Copying Gemfile"
|
18
19
|
template "Gemfile.erb", "Gemfile"
|
19
20
|
|
20
|
-
log :
|
21
|
+
log :bootup_log, "Running Bundler"
|
21
22
|
Bundler.with_clean_env do
|
22
23
|
run "bundle install"
|
23
24
|
end
|
24
25
|
|
25
|
-
log :
|
26
|
+
log :bootup_log, "Removing public/index.."
|
26
27
|
inside Rails.root do
|
27
28
|
run "rm public/index.html"
|
28
29
|
end
|
29
30
|
|
30
31
|
if @db == 'postgres'
|
31
|
-
|
32
|
+
@username = ask("\n\nPlease enter you postgres username", :blue)
|
33
|
+
@password = ask("\n\nPlease enter you postgres password. Leave blank if not applicable", :blue)
|
34
|
+
log :bootup_log, "Initializing database.yml"
|
32
35
|
template 'database.yml.erb', 'config/database.yml'
|
33
36
|
|
34
|
-
log :
|
37
|
+
log :bootup_log, "Creating database"
|
35
38
|
rake("db:create")
|
36
39
|
elsif @db == 'mongoid'
|
37
|
-
log :
|
40
|
+
log :bootup_log, "Generating Mongoid config"
|
38
41
|
generate "mongoid:config"
|
39
42
|
end
|
40
43
|
|
41
44
|
|
42
|
-
log :
|
45
|
+
log :bootup_log, "Installing Twitter Bootstrap"
|
43
46
|
generate "bootstrap:install"
|
44
47
|
|
45
|
-
log :
|
48
|
+
log :bootup_log, "Copy application.js & initialize datatables to #datatables - Remember to change sorting"
|
46
49
|
copy_file "application.js", "app/assets/javascripts/application.js"
|
47
50
|
|
48
|
-
log :
|
51
|
+
log :bootup_log, "Copying stylesheets"
|
49
52
|
copy_file "application.css", "app/assets/stylesheets/application.css"
|
50
53
|
|
51
|
-
log :
|
54
|
+
log :bootup_log, "Installing Simple Form"
|
52
55
|
generate "simple_form:install --bootstrap"
|
53
56
|
|
54
|
-
tests = ask("Would you like to get rid of the default testing framework & install Rspec with Guard?")
|
55
|
-
if
|
56
|
-
log :
|
57
|
+
tests = ask("\n\n Would you like to get rid of the default testing framework & install Rspec with Guard?", :blue)
|
58
|
+
if %w(y yes).include? tests
|
59
|
+
log :bootup_log, "Removing Tests.."
|
57
60
|
inside Rails.root do
|
58
61
|
run "rm -rf test/"
|
59
62
|
end
|
60
63
|
|
61
|
-
log :
|
64
|
+
log :bootup_log, "Setting up Rspec.."
|
62
65
|
generate "rspec:install"
|
63
66
|
|
64
|
-
log :
|
67
|
+
log :bootup_log, "Setting up Guard with a custom guardfile.."
|
65
68
|
copy_file "Guardfile", "Guardfile"
|
66
69
|
|
67
|
-
log :
|
70
|
+
log :bootup_log, "Setting up spork"
|
68
71
|
copy_file "spec_helper.rb", "spec/spec_helper.rb"
|
69
72
|
else
|
70
|
-
log :
|
73
|
+
log :bootup_log, "Skipping removal of tests"
|
71
74
|
end
|
75
|
+
log :bootup_log, "Initializing git repo"
|
76
|
+
inside Rails.root do
|
77
|
+
run "git init"
|
78
|
+
end
|
79
|
+
copy_file ".gitignore", "spec/spec_helper.rb"
|
80
|
+
inside Rails.root do
|
81
|
+
run "git add ."
|
82
|
+
run "git commit -m 'Initial Commit'"
|
83
|
+
end
|
84
|
+
|
85
|
+
auth = ask("\n\n Would you like authentication & related scaffolding to be setup?", :blue)
|
86
|
+
|
87
|
+
if %w(Y y Yes YES yes).include? auth
|
88
|
+
@model = ask("\n\n What would you like to call your user model? Default: User", :blue)
|
89
|
+
@model = "user" if @model.blank?
|
90
|
+
@model = @model.downcase.singularize
|
91
|
+
@models = @model.pluralize
|
92
|
+
|
93
|
+
log :bootup_log, "Installing Sorcery"
|
94
|
+
generate "sorcery:install"
|
95
|
+
|
96
|
+
|
97
|
+
log :bootup_log, "Copying models and migrations"
|
98
|
+
|
99
|
+
case @db
|
100
|
+
when 'mongoid'
|
101
|
+
template "authentication/models/user_mongoid.rb.erb", "app/models/#{@model}.rb"
|
102
|
+
inside Rails.root do
|
103
|
+
run "rm db/migrate/*"
|
104
|
+
end
|
105
|
+
else
|
106
|
+
template "authentication/models/user_others.rb.erb", "app/models/#{@model}.rb"
|
107
|
+
rake("db:migrate")
|
108
|
+
end
|
109
|
+
|
110
|
+
log :bootup_log, "Copying controllers"
|
111
|
+
template "authentication/controllers/users_controller.rb.erb", "app/controllers/#{@models}_controller.rb"
|
112
|
+
template "authentication/controllers/user_sessions_controller.rb.erb", "app/controllers/#{@model}_sessions_controller.rb"
|
113
|
+
copy_file "authentication/controllers/pages_controller.rb", "app/controllers/pages_controller.rb"
|
114
|
+
copy_file "authentication/controllers/application_controller.rb", "app/controllers/application_controller.rb"
|
115
|
+
|
116
|
+
log :bootup_log, "Copying views"
|
117
|
+
directory "authentication/views", "app/views"
|
118
|
+
|
119
|
+
log :bootup_log, "Copying initializers"
|
120
|
+
copy_file "authentication/sorcery.rb", "config/initializers/sorcery.rb"
|
121
|
+
|
122
|
+
log :bootup_log, "Copying initializers"
|
123
|
+
template "authentication/routes.rb.erb", "config/routes.rb"
|
72
124
|
|
125
|
+
inside Rails.root do
|
126
|
+
run "git add ."
|
127
|
+
run "git commit -am 'Authentication with sorcery.'"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
log :Installation_complete, "\n\n\n Installation Complete! Hope you saved some time. \n\n\n"
|
73
132
|
end
|
74
133
|
end
|
134
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler config
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
|
13
|
+
# Ignore all logfiles and tempfiles.
|
14
|
+
/log/*.log
|
15
|
+
/tmp
|
16
|
+
*.swp
|
17
|
+
*.swo
|
18
|
+
*.csv
|
19
|
+
*.tsv
|
20
|
+
/config/database.yml
|
21
|
+
.rvmrc
|
22
|
+
.rvmrc.*
|
23
|
+
*.god
|
24
|
+
/public/*
|
25
|
+
/config/application.yml
|
data/lib/generators/bootup/templates/authentication/controllers/user_sessions_controller.rb.erb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class <%= "#{@model}_sessions_controller".classify %> < ApplicationController
|
2
|
+
skip_before_filter :require_login, :except => [:destroy]
|
3
|
+
def new
|
4
|
+
current_user and redirect_to user_path(current_user)
|
5
|
+
@user = <%= @model.classify %>.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
respond_to do |format|
|
10
|
+
if @user = login(params[:email],params[:password])
|
11
|
+
format.html { redirect_back_or_to(@user, :notice => 'Login successful.') }
|
12
|
+
format.xml { render :xml => @user, :status => :created, :location => @user }
|
13
|
+
else
|
14
|
+
format.html { flash.now[:alert] = "Login failed."; render :action => "new" }
|
15
|
+
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
logout
|
22
|
+
redirect_to(root_path, :alert => 'Logged out!')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class <%= "#{@models}_controller".classify %> < ApplicationController
|
2
|
+
skip_before_filter :require_login, :only => [:new, :create]
|
3
|
+
# GET /users
|
4
|
+
# GET /users.json
|
5
|
+
def index
|
6
|
+
@users = <%= @model.classify %>.all
|
7
|
+
|
8
|
+
respond_to do |format|
|
9
|
+
format.html # index.html.erb
|
10
|
+
format.json { render json: @users }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /users/1
|
15
|
+
# GET /users/1.json
|
16
|
+
def show
|
17
|
+
@user = <%= @model.classify %>.find(params[:id])
|
18
|
+
|
19
|
+
respond_to do |format|
|
20
|
+
format.html # show.html.erb
|
21
|
+
format.json { render json: @user }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /users/new
|
26
|
+
# GET /users/new.json
|
27
|
+
def new
|
28
|
+
@user = <%= @model.classify %>.new
|
29
|
+
|
30
|
+
respond_to do |format|
|
31
|
+
format.html # new.html.erb
|
32
|
+
format.json { render json: @user }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# GET /users/1/edit
|
37
|
+
def edit
|
38
|
+
@user = <%= @model.classify %>.find(params[:id])
|
39
|
+
end
|
40
|
+
|
41
|
+
# POST /users
|
42
|
+
# POST /users.json
|
43
|
+
def create
|
44
|
+
@user = <%= @model.classify %>.new(params[:user])
|
45
|
+
if @user.save
|
46
|
+
reset_session
|
47
|
+
auto_login(@user)
|
48
|
+
redirect_to user_path(@user), notice: "Your Account has been created."
|
49
|
+
else
|
50
|
+
render action: "new"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# PUT /users/1
|
55
|
+
# PUT /users/1.json
|
56
|
+
def update
|
57
|
+
@user = <%= @model.classify %>.find(params[:id])
|
58
|
+
|
59
|
+
respond_to do |format|
|
60
|
+
if @user.update_attributes(params[:user])
|
61
|
+
format.html { redirect_to @user, notice: '<%= @model.classify %> was successfully updated.' }
|
62
|
+
format.json { head :no_content }
|
63
|
+
else
|
64
|
+
format.html { render action: "edit" }
|
65
|
+
format.json { render json: @user.errors, status: :unprocessable_entity }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# DELETE /users/1
|
71
|
+
# DELETE /users/1.json
|
72
|
+
def destroy
|
73
|
+
@user = <%= @model.classify %>.find(params[:id])
|
74
|
+
@user.destroy
|
75
|
+
|
76
|
+
respond_to do |format|
|
77
|
+
format.html { redirect_to users_url }
|
78
|
+
format.json { head :no_content }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class SorceryCore < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :users do |t|
|
4
|
+
t.string :username, :null => false # if you use another field as a username, for example email, you can safely remove this field.
|
5
|
+
t.string :email, :default => nil # if you use this field as a username, you might want to make it :null => false.
|
6
|
+
t.string :crypted_password, :default => nil
|
7
|
+
t.string :salt, :default => nil
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :users
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class SorceryCore < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :users do |t|
|
4
|
+
t.string :username, :null => false # if you use another field as a username, for example email, you can safely remove this field.
|
5
|
+
t.string :email, :default => nil # if you use this field as a username, you might want to make it :null => false.
|
6
|
+
t.string :crypted_password, :default => nil
|
7
|
+
t.string :salt, :default => nil
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :users
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class <%= @model.classify %>
|
2
|
+
include Mongoid::Document
|
3
|
+
authenticates_with_sorcery!
|
4
|
+
|
5
|
+
field :username, type: String
|
6
|
+
field :email, type: String
|
7
|
+
field :crypted_password, type: String
|
8
|
+
field :salt, type: String
|
9
|
+
|
10
|
+
attr_accessible :username, :email, :password, :password_confirmation
|
11
|
+
|
12
|
+
validates_length_of :password, :minimum => 5, :message => "password must be at least 5 characters long", :if => :password
|
13
|
+
validates_confirmation_of :password, :message => "should match confirmation", :if => :password
|
14
|
+
validates_uniqueness_of :email, :username
|
15
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class <%= @model.classify %> < ActiveRecord::Base
|
2
|
+
authenticates_with_sorcery!
|
3
|
+
attr_accessible :username, :email, :password, :password_confirmation
|
4
|
+
validates_length_of :password, :minimum => 5, :message => "password must be at least 5 characters long", :if => :password
|
5
|
+
validates_confirmation_of :password, :message => "should match confirmation", :if => :password
|
6
|
+
validates_uniqueness_of :username, :email
|
7
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= Rails.application.class.parent %>::Application.routes.draw do
|
2
|
+
|
3
|
+
get "pages/home"
|
4
|
+
root :to => 'pages#home'
|
5
|
+
|
6
|
+
resources :<%= "#{@model}_sessions" %>
|
7
|
+
resources :<%= @models %>
|
8
|
+
|
9
|
+
match 'login' => '<%= "#{@model}_sessions" %>#new', :as => :login
|
10
|
+
match 'logout' => '<%= "#{@model}_sessions" %>#destroy', :as => :logout
|
11
|
+
end
|
@@ -0,0 +1,398 @@
|
|
1
|
+
# The first thing you need to configure is which modules you need in your app.
|
2
|
+
# The default is nothing which will include only core features (password encryption, login/logout).
|
3
|
+
# Available submodules are: :user_activation, :http_basic_auth, :remember_me,
|
4
|
+
# :reset_password, :session_timeout, :brute_force_protection, :activity_logging, :external
|
5
|
+
Rails.application.config.sorcery.submodules = []
|
6
|
+
|
7
|
+
# Here you can configure each submodule's features.
|
8
|
+
Rails.application.config.sorcery.configure do |config|
|
9
|
+
# -- core --
|
10
|
+
# What controller action to call for non-authenticated users. You can also
|
11
|
+
# override the 'not_authenticated' method of course.
|
12
|
+
# Default: `:not_authenticated`
|
13
|
+
#
|
14
|
+
# config.not_authenticated_action =
|
15
|
+
|
16
|
+
|
17
|
+
# When a non logged in user tries to enter a page that requires login, save
|
18
|
+
# the URL he wanted to reach, and send him there after login, using 'redirect_back_or_to'.
|
19
|
+
# Default: `true`
|
20
|
+
#
|
21
|
+
# config.save_return_to_url =
|
22
|
+
|
23
|
+
|
24
|
+
# Set domain option for cookies; Useful for remember_me submodule.
|
25
|
+
# Default: `nil`
|
26
|
+
#
|
27
|
+
# config.cookie_domain =
|
28
|
+
|
29
|
+
|
30
|
+
# -- session timeout --
|
31
|
+
# How long in seconds to keep the session alive.
|
32
|
+
# Default: `3600`
|
33
|
+
#
|
34
|
+
# config.session_timeout =
|
35
|
+
|
36
|
+
|
37
|
+
# Use the last action as the beginning of session timeout.
|
38
|
+
# Default: `false`
|
39
|
+
#
|
40
|
+
# config.session_timeout_from_last_action =
|
41
|
+
|
42
|
+
|
43
|
+
# -- http_basic_auth --
|
44
|
+
# What realm to display for which controller name. For example {"My App" => "Application"}
|
45
|
+
# Default: `{"application" => "Application"}`
|
46
|
+
#
|
47
|
+
# config.controller_to_realm_map =
|
48
|
+
|
49
|
+
|
50
|
+
# -- activity logging --
|
51
|
+
# will register the time of last user login, every login.
|
52
|
+
# Default: `true`
|
53
|
+
#
|
54
|
+
# config.register_login_time =
|
55
|
+
|
56
|
+
|
57
|
+
# will register the time of last user logout, every logout.
|
58
|
+
# Default: `true`
|
59
|
+
#
|
60
|
+
# config.register_logout_time =
|
61
|
+
|
62
|
+
|
63
|
+
# will register the time of last user action, every action.
|
64
|
+
# Default: `true`
|
65
|
+
#
|
66
|
+
# config.register_last_activity_time =
|
67
|
+
|
68
|
+
|
69
|
+
# -- external --
|
70
|
+
# What providers are supported by this app, i.e. [:twitter, :facebook, :github, :google, :liveid] .
|
71
|
+
# Default: `[]`
|
72
|
+
#
|
73
|
+
# config.external_providers =
|
74
|
+
|
75
|
+
|
76
|
+
# You can change it by your local ca_file. i.e. '/etc/pki/tls/certs/ca-bundle.crt'
|
77
|
+
# Path to ca_file. By default use a internal ca-bundle.crt.
|
78
|
+
# Default: `'path/to/ca_file'`
|
79
|
+
#
|
80
|
+
# config.ca_file =
|
81
|
+
|
82
|
+
|
83
|
+
# Twitter wil not accept any requests nor redirect uri containing localhost,
|
84
|
+
# make sure you use 0.0.0.0:3000 to access your app in development
|
85
|
+
#
|
86
|
+
# config.twitter.key = ""
|
87
|
+
# config.twitter.secret = ""
|
88
|
+
# config.twitter.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=twitter"
|
89
|
+
# config.twitter.user_info_mapping = {:email => "screen_name"}
|
90
|
+
#
|
91
|
+
# config.facebook.key = ""
|
92
|
+
# config.facebook.secret = ""
|
93
|
+
# config.facebook.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=facebook"
|
94
|
+
# config.facebook.user_info_mapping = {:email => "name"}
|
95
|
+
#
|
96
|
+
# config.github.key = ""
|
97
|
+
# config.github.secret = ""
|
98
|
+
# config.github.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=github"
|
99
|
+
# config.github.user_info_mapping = {:email => "name"}
|
100
|
+
#
|
101
|
+
# config.google.key = ""
|
102
|
+
# config.google.secret = ""
|
103
|
+
# config.google.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=google"
|
104
|
+
# config.google.user_info_mapping = {:email => "email", :username => "name"}
|
105
|
+
#
|
106
|
+
# To use liveid in development mode you have to replace mydomain.com with
|
107
|
+
# a valid domain even in development. To use a valid domain in development
|
108
|
+
# simply add your domain in your /etc/hosts file in front of 127.0.0.1
|
109
|
+
#
|
110
|
+
# config.liveid.key = ""
|
111
|
+
# config.liveid.secret = ""
|
112
|
+
# config.liveid.callback_url = "http://mydomain.com:3000/oauth/callback?provider=liveid"
|
113
|
+
# config.liveid.user_info_mapping = {:username => "name"}
|
114
|
+
|
115
|
+
|
116
|
+
# --- user config ---
|
117
|
+
config.user_config do |user|
|
118
|
+
# -- core --
|
119
|
+
# specify username attributes, for example: [:username, :email].
|
120
|
+
# Default: `[:username]`
|
121
|
+
#
|
122
|
+
user.username_attribute_names = [:username, :email]
|
123
|
+
|
124
|
+
|
125
|
+
# change *virtual* password attribute, the one which is used until an encrypted one is generated.
|
126
|
+
# Default: `:password`
|
127
|
+
#
|
128
|
+
# user.password_attribute_name =
|
129
|
+
|
130
|
+
|
131
|
+
# downcase the username before trying to authenticate, default is false
|
132
|
+
# Default: `false`
|
133
|
+
#
|
134
|
+
# user.downcase_username_before_authenticating =
|
135
|
+
|
136
|
+
|
137
|
+
# change default email attribute.
|
138
|
+
# Default: `:email`
|
139
|
+
#
|
140
|
+
# user.email_attribute_name =
|
141
|
+
|
142
|
+
|
143
|
+
# change default crypted_password attribute.
|
144
|
+
# Default: `:crypted_password`
|
145
|
+
#
|
146
|
+
# user.crypted_password_attribute_name =
|
147
|
+
|
148
|
+
|
149
|
+
# what pattern to use to join the password with the salt
|
150
|
+
# Default: `""`
|
151
|
+
#
|
152
|
+
# user.salt_join_token =
|
153
|
+
|
154
|
+
|
155
|
+
# change default salt attribute.
|
156
|
+
# Default: `:salt`
|
157
|
+
#
|
158
|
+
# user.salt_attribute_name =
|
159
|
+
|
160
|
+
|
161
|
+
# how many times to apply encryption to the password.
|
162
|
+
# Default: `nil`
|
163
|
+
#
|
164
|
+
# user.stretches =
|
165
|
+
|
166
|
+
|
167
|
+
# encryption key used to encrypt reversible encryptions such as AES256.
|
168
|
+
# WARNING: If used for users' passwords, changing this key will leave passwords undecryptable!
|
169
|
+
# Default: `nil`
|
170
|
+
#
|
171
|
+
# user.encryption_key =
|
172
|
+
|
173
|
+
|
174
|
+
# use an external encryption class.
|
175
|
+
# Default: `nil`
|
176
|
+
#
|
177
|
+
# user.custom_encryption_provider =
|
178
|
+
|
179
|
+
|
180
|
+
# encryption algorithm name. See 'encryption_algorithm=' for available options.
|
181
|
+
# Default: `:bcrypt`
|
182
|
+
#
|
183
|
+
# user.encryption_algorithm =
|
184
|
+
|
185
|
+
|
186
|
+
# make this configuration inheritable for subclasses. Useful for ActiveRecord's STI.
|
187
|
+
# Default: `false`
|
188
|
+
#
|
189
|
+
# user.subclasses_inherit_config =
|
190
|
+
|
191
|
+
|
192
|
+
# -- user_activation --
|
193
|
+
# the attribute name to hold activation state (active/pending).
|
194
|
+
# Default: `:activation_state`
|
195
|
+
#
|
196
|
+
# user.activation_state_attribute_name =
|
197
|
+
|
198
|
+
|
199
|
+
# the attribute name to hold activation code (sent by email).
|
200
|
+
# Default: `:activation_token`
|
201
|
+
#
|
202
|
+
# user.activation_token_attribute_name =
|
203
|
+
|
204
|
+
|
205
|
+
# the attribute name to hold activation code expiration date.
|
206
|
+
# Default: `:activation_token_expires_at`
|
207
|
+
#
|
208
|
+
# user.activation_token_expires_at_attribute_name =
|
209
|
+
|
210
|
+
|
211
|
+
# how many seconds before the activation code expires. nil for never expires.
|
212
|
+
# Default: `nil`
|
213
|
+
#
|
214
|
+
# user.activation_token_expiration_period =
|
215
|
+
|
216
|
+
|
217
|
+
# your mailer class. Required.
|
218
|
+
# Default: `nil`
|
219
|
+
#
|
220
|
+
# user.user_activation_mailer =
|
221
|
+
|
222
|
+
|
223
|
+
# when true sorcery will not automatically
|
224
|
+
# email activation details and allow you to
|
225
|
+
# manually handle how and when email is sent.
|
226
|
+
# Default: `false`
|
227
|
+
#
|
228
|
+
# user.activation_mailer_disabled =
|
229
|
+
|
230
|
+
|
231
|
+
# activation needed email method on your mailer class.
|
232
|
+
# Default: `:activation_needed_email`
|
233
|
+
#
|
234
|
+
# user.activation_needed_email_method_name =
|
235
|
+
|
236
|
+
|
237
|
+
# activation success email method on your mailer class.
|
238
|
+
# Default: `:activation_success_email`
|
239
|
+
#
|
240
|
+
# user.activation_success_email_method_name =
|
241
|
+
|
242
|
+
|
243
|
+
# do you want to prevent or allow users that did not activate by email to login?
|
244
|
+
# Default: `true`
|
245
|
+
#
|
246
|
+
# user.prevent_non_active_users_to_login =
|
247
|
+
|
248
|
+
|
249
|
+
# -- reset_password --
|
250
|
+
# reset password code attribute name.
|
251
|
+
# Default: `:reset_password_token`
|
252
|
+
#
|
253
|
+
# user.reset_password_token_attribute_name =
|
254
|
+
|
255
|
+
|
256
|
+
# expires at attribute name.
|
257
|
+
# Default: `:reset_password_token_expires_at`
|
258
|
+
#
|
259
|
+
# user.reset_password_token_expires_at_attribute_name =
|
260
|
+
|
261
|
+
|
262
|
+
# when was email sent, used for hammering protection.
|
263
|
+
# Default: `:reset_password_email_sent_at`
|
264
|
+
#
|
265
|
+
# user.reset_password_email_sent_at_attribute_name =
|
266
|
+
|
267
|
+
|
268
|
+
# mailer class. Needed.
|
269
|
+
# Default: `nil`
|
270
|
+
#
|
271
|
+
# user.reset_password_mailer =
|
272
|
+
|
273
|
+
|
274
|
+
# reset password email method on your mailer class.
|
275
|
+
# Default: `:reset_password_email`
|
276
|
+
#
|
277
|
+
# user.reset_password_email_method_name =
|
278
|
+
|
279
|
+
|
280
|
+
# when true sorcery will not automatically
|
281
|
+
# email password reset details and allow you to
|
282
|
+
# manually handle how and when email is sent
|
283
|
+
# Default: `false`
|
284
|
+
#
|
285
|
+
# user.reset_password_mailer_disabled =
|
286
|
+
|
287
|
+
|
288
|
+
# how many seconds before the reset request expires. nil for never expires.
|
289
|
+
# Default: `nil`
|
290
|
+
#
|
291
|
+
# user.reset_password_expiration_period =
|
292
|
+
|
293
|
+
|
294
|
+
# hammering protection, how long to wait before allowing another email to be sent.
|
295
|
+
# Default: `5 * 60`
|
296
|
+
#
|
297
|
+
# user.reset_password_time_between_emails =
|
298
|
+
|
299
|
+
|
300
|
+
# -- brute_force_protection --
|
301
|
+
# Failed logins attribute name.
|
302
|
+
# Default: `:failed_logins_count`
|
303
|
+
#
|
304
|
+
# user.failed_logins_count_attribute_name =
|
305
|
+
|
306
|
+
|
307
|
+
# This field indicates whether user is banned and when it will be active again.
|
308
|
+
# Default: `:lock_expires_at`
|
309
|
+
#
|
310
|
+
# user.lock_expires_at_attribute_name =
|
311
|
+
|
312
|
+
|
313
|
+
# How many failed logins allowed.
|
314
|
+
# Default: `50`
|
315
|
+
#
|
316
|
+
# user.consecutive_login_retries_amount_limit =
|
317
|
+
|
318
|
+
|
319
|
+
# How long the user should be banned. in seconds. 0 for permanent.
|
320
|
+
# Default: `60 * 60`
|
321
|
+
#
|
322
|
+
# user.login_lock_time_period =
|
323
|
+
|
324
|
+
# Unlock token attribute name
|
325
|
+
# Default: `:unlock_token`
|
326
|
+
#
|
327
|
+
# user.unlock_token_attribute_name =
|
328
|
+
|
329
|
+
# Unlock token mailer method
|
330
|
+
# Default: `:send_unlock_token_email`
|
331
|
+
#
|
332
|
+
# user.unlock_token_email_method_name =
|
333
|
+
|
334
|
+
# when true sorcery will not automatically
|
335
|
+
# send email with unlock token
|
336
|
+
# Default: `false`
|
337
|
+
#
|
338
|
+
# user.unlock_token_mailer_disabled = true
|
339
|
+
|
340
|
+
# Unlock token mailer class
|
341
|
+
# Default: `nil`
|
342
|
+
#
|
343
|
+
# user.unlock_token_mailer = UserMailer
|
344
|
+
|
345
|
+
# -- activity logging --
|
346
|
+
# Last login attribute name.
|
347
|
+
# Default: `:last_login_at`
|
348
|
+
#
|
349
|
+
# user.last_login_at_attribute_name =
|
350
|
+
|
351
|
+
|
352
|
+
# Last logout attribute name.
|
353
|
+
# Default: `:last_logout_at`
|
354
|
+
#
|
355
|
+
# user.last_logout_at_attribute_name =
|
356
|
+
|
357
|
+
|
358
|
+
# Last activity attribute name.
|
359
|
+
# Default: `:last_activity_at`
|
360
|
+
#
|
361
|
+
# user.last_activity_at_attribute_name =
|
362
|
+
|
363
|
+
|
364
|
+
# How long since last activity is he user defined logged out?
|
365
|
+
# Default: `10 * 60`
|
366
|
+
#
|
367
|
+
# user.activity_timeout =
|
368
|
+
|
369
|
+
|
370
|
+
# -- external --
|
371
|
+
# Class which holds the various external provider data for this user.
|
372
|
+
# Default: `nil`
|
373
|
+
#
|
374
|
+
# user.authentications_class =
|
375
|
+
|
376
|
+
|
377
|
+
# User's identifier in authentications class.
|
378
|
+
# Default: `:user_id`
|
379
|
+
#
|
380
|
+
# user.authentications_user_id_attribute_name =
|
381
|
+
|
382
|
+
|
383
|
+
# Provider's identifier in authentications class.
|
384
|
+
# Default: `:provider`
|
385
|
+
#
|
386
|
+
# user.provider_attribute_name =
|
387
|
+
|
388
|
+
|
389
|
+
# User's external unique identifier in authentications class.
|
390
|
+
# Default: `:uid`
|
391
|
+
#
|
392
|
+
# user.provider_uid_attribute_name =
|
393
|
+
end
|
394
|
+
|
395
|
+
# This line must come after the 'user config' block.
|
396
|
+
# Define which model authenticates with sorcery.
|
397
|
+
config.user_class = "User"
|
398
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
|
+
<title><%= content_for?(:title) ? yield(:title) : "Bootup" %></title>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
|
10
|
+
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
|
11
|
+
<!--[if lt IE 9]>
|
12
|
+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
|
13
|
+
<![endif]-->
|
14
|
+
|
15
|
+
<%= stylesheet_link_tag "application", :media => "all" %>
|
16
|
+
<%= javascript_include_tag "application" %>
|
17
|
+
|
18
|
+
<!-- For third-generation iPad with high-resolution Retina display: -->
|
19
|
+
<!-- Size should be 144 x 144 pixels -->
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
|
23
|
+
<div class="navbar navbar-fixed-top">
|
24
|
+
<div class="navbar-inner">
|
25
|
+
<div class="container">
|
26
|
+
<a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse">
|
27
|
+
<span class="icon-bar"></span>
|
28
|
+
<span class="icon-bar"></span>
|
29
|
+
<span class="icon-bar"></span>
|
30
|
+
</a>
|
31
|
+
<% if current_user -%>
|
32
|
+
<% link = user_path(current_user) -%>
|
33
|
+
<% else -%>
|
34
|
+
<% link = root_path -%>
|
35
|
+
<% end -%>
|
36
|
+
<a class="brand" href="<%= link %>">Bootup</a>
|
37
|
+
<div class="container nav-collapse">
|
38
|
+
<ul class="nav pull-right">
|
39
|
+
<% if current_user -%>
|
40
|
+
<li><%= link_to "Edit Profile", edit_user_path(current_user.id) %></li>
|
41
|
+
<li><%= link_to "Logout", :logout %></li>
|
42
|
+
<% else -%>
|
43
|
+
<li><%= link_to "Register", new_user_path %></li>
|
44
|
+
<li><%= link_to "Login", :login %></li>
|
45
|
+
<% end -%>
|
46
|
+
</ul>
|
47
|
+
</div><!--/.nav-collapse -->
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<div class="container">
|
53
|
+
<div class="row">
|
54
|
+
<br><br><br>
|
55
|
+
<% flash.each do |name, msg| %>
|
56
|
+
<% unless msg.blank? -%>
|
57
|
+
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
|
58
|
+
<a class="close" data-dismiss="alert">×</a>
|
59
|
+
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
|
60
|
+
</div>
|
61
|
+
<% end %>
|
62
|
+
<% end -%>
|
63
|
+
<div class="span12">
|
64
|
+
<%= yield %>
|
65
|
+
</div>
|
66
|
+
</div><!--/row-->
|
67
|
+
|
68
|
+
<footer class="center">
|
69
|
+
<p>© Company 2012</p>
|
70
|
+
</footer>
|
71
|
+
|
72
|
+
</div> <!-- /container -->
|
73
|
+
|
74
|
+
<!-- Javascripts
|
75
|
+
================================================== -->
|
76
|
+
<!-- Placed at the end of the document so the pages load faster -->
|
77
|
+
|
78
|
+
</body>
|
79
|
+
</html>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<%= form_tag user_sessions_path, :method => :post do %>
|
2
|
+
<div class="form-inputs">
|
3
|
+
<%= label_tag :email %>
|
4
|
+
<%= text_field_tag :email %>
|
5
|
+
<%= label_tag :password %>
|
6
|
+
<%= password_field_tag :password %>
|
7
|
+
</div>
|
8
|
+
<div class="form-inputs">
|
9
|
+
<hr>
|
10
|
+
<%= submit_tag " Login ", class: "btn btn-primary" %>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= simple_form_for(@user) do |f| %>
|
2
|
+
<%= f.error_notification %>
|
3
|
+
|
4
|
+
<div class="form-inputs">
|
5
|
+
<%= f.input :username %>
|
6
|
+
<%= f.input :email %>
|
7
|
+
<%= f.input :password %>
|
8
|
+
<%= f.input :password_confirmation %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="form-actions">
|
12
|
+
<%= f.button :submit, class: "btn btn-primary" %>
|
13
|
+
<%= link_to 'Back', root_path, class: "btn" %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<h1>Listing users</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th>Username</th>
|
6
|
+
<th>Email</th>
|
7
|
+
<th>Crypted password</th>
|
8
|
+
<th>Salt</th>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
|
14
|
+
<% @users.each do |user| %>
|
15
|
+
<tr>
|
16
|
+
<td><%= user.username %></td>
|
17
|
+
<td><%= user.email %></td>
|
18
|
+
<td><%= user.crypted_password %></td>
|
19
|
+
<td><%= user.salt %></td>
|
20
|
+
<td><%= link_to 'Show', user %></td>
|
21
|
+
<td><%= link_to 'Edit', edit_user_path(user) %></td>
|
22
|
+
<td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
23
|
+
</tr>
|
24
|
+
<% end %>
|
25
|
+
</table>
|
26
|
+
|
27
|
+
<br />
|
28
|
+
|
29
|
+
<%= link_to 'New User', new_user_path %>
|
@@ -1,7 +1,8 @@
|
|
1
1
|
development:
|
2
2
|
adapter: postgresql
|
3
3
|
database: <%= app_name %>_development
|
4
|
-
username:
|
4
|
+
username: <%= @username unless @username.blank? %>
|
5
|
+
pasword: <%= @password unless @password.blank? %>
|
5
6
|
encoding: utf8
|
6
7
|
pool: 5
|
7
8
|
timeout: 5000
|
@@ -9,7 +10,8 @@ development:
|
|
9
10
|
test:
|
10
11
|
adapter: postgresql
|
11
12
|
database: <%= app_name %>_test
|
12
|
-
username:
|
13
|
+
username: <%= @username unless @username.blank? %>
|
14
|
+
pasword: <%= @password unless @password.blank? %>
|
13
15
|
encoding: utf8
|
14
16
|
pool: 5
|
15
17
|
timeout: 5000
|
@@ -17,7 +19,7 @@ test:
|
|
17
19
|
production:
|
18
20
|
adapter: postgresql
|
19
21
|
database: <%= app_name %>_production
|
20
|
-
username:
|
22
|
+
username:
|
21
23
|
encoding: utf8
|
22
24
|
pool: 5
|
23
25
|
timeout: 5000
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Helps create a new rails app quickly
|
15
15
|
email:
|
@@ -29,10 +29,33 @@ files:
|
|
29
29
|
- lib/bootup/version.rb
|
30
30
|
- lib/generators/bootup/USAGE
|
31
31
|
- lib/generators/bootup/bootup_generator.rb
|
32
|
+
- lib/generators/bootup/templates/.gitignore
|
32
33
|
- lib/generators/bootup/templates/Gemfile.erb
|
33
34
|
- lib/generators/bootup/templates/Guardfile
|
34
35
|
- lib/generators/bootup/templates/application.css
|
35
36
|
- lib/generators/bootup/templates/application.js
|
37
|
+
- lib/generators/bootup/templates/authentication/controllers/application_controller.rb
|
38
|
+
- lib/generators/bootup/templates/authentication/controllers/pages_controller.rb
|
39
|
+
- lib/generators/bootup/templates/authentication/controllers/user_sessions_controller.rb.erb
|
40
|
+
- lib/generators/bootup/templates/authentication/controllers/users_controller.rb.erb
|
41
|
+
- lib/generators/bootup/templates/authentication/migrate/20121128071307_sorcery_core.rb
|
42
|
+
- lib/generators/bootup/templates/authentication/models/.gitkeep
|
43
|
+
- lib/generators/bootup/templates/authentication/models/sorcery_core.rb.erb
|
44
|
+
- lib/generators/bootup/templates/authentication/models/user_mongoid.rb.erb
|
45
|
+
- lib/generators/bootup/templates/authentication/models/user_others.rb.erb
|
46
|
+
- lib/generators/bootup/templates/authentication/routes.rb.erb
|
47
|
+
- lib/generators/bootup/templates/authentication/sorcery.rb
|
48
|
+
- lib/generators/bootup/templates/authentication/views/layouts/application.html.erb
|
49
|
+
- lib/generators/bootup/templates/authentication/views/pages/home.html.erb
|
50
|
+
- lib/generators/bootup/templates/authentication/views/user_sessions/_form.html.erb
|
51
|
+
- lib/generators/bootup/templates/authentication/views/user_sessions/create.html.erb
|
52
|
+
- lib/generators/bootup/templates/authentication/views/user_sessions/destroy.html.erb
|
53
|
+
- lib/generators/bootup/templates/authentication/views/user_sessions/new.html.erb
|
54
|
+
- lib/generators/bootup/templates/authentication/views/users/_form.html.erb
|
55
|
+
- lib/generators/bootup/templates/authentication/views/users/edit.html.erb
|
56
|
+
- lib/generators/bootup/templates/authentication/views/users/index.html.erb
|
57
|
+
- lib/generators/bootup/templates/authentication/views/users/new.html.erb
|
58
|
+
- lib/generators/bootup/templates/authentication/views/users/show.html.erb
|
36
59
|
- lib/generators/bootup/templates/database.yml.erb
|
37
60
|
- lib/generators/bootup/templates/spec_helper.rb
|
38
61
|
homepage: https://github.com/recklessrahul/bootup
|