Skip to content

Commit c93fd0c

Browse files
Install devise, add a user, and install devise views.
1 parent 26bb510 commit c93fd0c

27 files changed

+604
-267
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ gem 'rails', '3.2.13'
66
# gem 'rails', :git => 'git://github.com/rails/rails.git'
77

88
gem 'sqlite3'
9-
9+
gem 'devise'
1010

1111
# Gems used only for assets and not required
1212
# in production environments by default.

Gemfile.lock

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ GEM
2929
i18n (= 0.6.1)
3030
multi_json (~> 1.0)
3131
arel (3.0.2)
32+
bcrypt-ruby (3.0.1)
3233
builder (3.0.4)
3334
coffee-rails (3.2.2)
3435
coffee-script (>= 2.2.0)
@@ -37,6 +38,11 @@ GEM
3738
coffee-script-source
3839
execjs
3940
coffee-script-source (1.6.2)
41+
devise (2.2.4)
42+
bcrypt-ruby (~> 3.0)
43+
orm_adapter (~> 0.1)
44+
railties (~> 3.1)
45+
warden (~> 1.2.1)
4046
erubis (2.7.0)
4147
execjs (1.4.0)
4248
multi_json (~> 1.0)
@@ -53,6 +59,7 @@ GEM
5359
treetop (~> 1.4.8)
5460
mime-types (1.23)
5561
multi_json (1.7.3)
62+
orm_adapter (0.4.0)
5663
polyglot (0.3.3)
5764
rack (1.4.5)
5865
rack-cache (1.2)
@@ -99,12 +106,15 @@ GEM
99106
uglifier (2.0.1)
100107
execjs (>= 0.3.0)
101108
multi_json (~> 1.0, >= 1.0.2)
109+
warden (1.2.1)
110+
rack (>= 1.0)
102111

103112
PLATFORMS
104113
ruby
105114

106115
DEPENDENCIES
107116
coffee-rails (~> 3.2.1)
117+
devise
108118
jquery-rails
109119
rails (= 3.2.13)
110120
sass-rails (~> 3.2.3)

app/models/user.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class User < ActiveRecord::Base
2+
# Include default devise modules. Others available are:
3+
# :token_authenticatable, :confirmable,
4+
# :lockable, :timeoutable and :omniauthable
5+
devise :database_authenticatable, :registerable,
6+
:recoverable, :rememberable, :trackable, :validatable
7+
8+
# Setup accessible (or protected) attributes for your model
9+
attr_accessible :email, :password, :password_confirmation, :remember_me,
10+
:first_name, :last_name, :profile_name
11+
# attr_accessible :title, :body
12+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<h2>Resend confirmation instructions</h2>
2+
3+
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
4+
<%= devise_error_messages! %>
5+
6+
<div><%= f.label :email %><br />
7+
<%= f.email_field :email, :autofocus => true %></div>
8+
9+
<div><%= f.submit "Resend confirmation instructions" %></div>
10+
<% end %>
11+
12+
<%= render "devise/shared/links" %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p>Welcome <%= @email %>!</p>
2+
3+
<p>You can confirm your account email through the link below:</p>
4+
5+
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<p>Hello <%= @resource.email %>!</p>
2+
3+
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
4+
5+
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
6+
7+
<p>If you didn't request this, please ignore this email.</p>
8+
<p>Your password won't change until you access the link above and create a new one.</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p>Hello <%= @resource.email %>!</p>
2+
3+
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
4+
5+
<p>Click the link below to unlock your account:</p>
6+
7+
<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h2>Change your password</h2>
2+
3+
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
4+
<%= devise_error_messages! %>
5+
<%= f.hidden_field :reset_password_token %>
6+
7+
<div><%= f.label :password, "New password" %><br />
8+
<%= f.password_field :password, :autofocus => true %></div>
9+
10+
<div><%= f.label :password_confirmation, "Confirm new password" %><br />
11+
<%= f.password_field :password_confirmation %></div>
12+
13+
<div><%= f.submit "Change my password" %></div>
14+
<% end %>
15+
16+
<%= render "devise/shared/links" %>
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<h2>Forgot your password?</h2>
2+
3+
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
4+
<%= devise_error_messages! %>
5+
6+
<div><%= f.label :email %><br />
7+
<%= f.email_field :email, :autofocus => true %></div>
8+
9+
<div><%= f.submit "Send me reset password instructions" %></div>
10+
<% end %>
11+
12+
<%= render "devise/shared/links" %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<h2>Edit <%= resource_name.to_s.humanize %></h2>
2+
3+
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4+
<%= devise_error_messages! %>
5+
6+
<div><%= f.label :email %><br />
7+
<%= f.email_field :email, :autofocus => true %></div>
8+
9+
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
10+
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
11+
<% end %>
12+
13+
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
14+
<%= f.password_field :password, :autocomplete => "off" %></div>
15+
16+
<div><%= f.label :password_confirmation %><br />
17+
<%= f.password_field :password_confirmation %></div>
18+
19+
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
20+
<%= f.password_field :current_password %></div>
21+
22+
<div><%= f.submit "Update" %></div>
23+
<% end %>
24+
25+
<h3>Cancel my account</h3>
26+
27+
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %></p>
28+
29+
<%= link_to "Back", :back %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<h2>Sign up</h2>
2+
3+
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
4+
<%= devise_error_messages! %>
5+
6+
<div><%= f.label :first_name %><br />
7+
<%= f.text_field :first_name %></div>
8+
<div><%= f.label :last_name %><br />
9+
<%= f.text_field :last_name %></div>
10+
<div><%= f.label :profile_name %><br />
11+
<%= f.text_field :profile_name %></div>
12+
13+
14+
<div><%= f.label :email %><br />
15+
<%= f.email_field :email, :autofocus => true %></div>
16+
17+
<div><%= f.label :password %><br />
18+
<%= f.password_field :password %></div>
19+
20+
<div><%= f.label :password_confirmation %><br />
21+
<%= f.password_field :password_confirmation %></div>
22+
23+
<div><%= f.submit "Sign up" %></div>
24+
<% end %>
25+
26+
<%= render "devise/shared/links" %>
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<h2>Sign in</h2>
2+
3+
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
4+
<div><%= f.label :email %><br />
5+
<%= f.email_field :email, :autofocus => true %></div>
6+
7+
<div><%= f.label :password %><br />
8+
<%= f.password_field :password %></div>
9+
10+
<% if devise_mapping.rememberable? -%>
11+
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
12+
<% end -%>
13+
14+
<div><%= f.submit "Sign in" %></div>
15+
<% end %>
16+
17+
<%= render "devise/shared/links" %>

app/views/devise/shared/_links.erb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<%- if controller_name != 'sessions' %>
2+
<%= link_to "Sign in", new_session_path(resource_name) %><br />
3+
<% end -%>
4+
5+
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6+
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
7+
<% end -%>
8+
9+
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
10+
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
11+
<% end -%>
12+
13+
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
14+
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
15+
<% end -%>
16+
17+
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
18+
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
19+
<% end -%>
20+
21+
<%- if devise_mapping.omniauthable? %>
22+
<%- resource_class.omniauth_providers.each do |provider| %>
23+
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
24+
<% end -%>
25+
<% end -%>

app/views/devise/unlocks/new.html.erb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<h2>Resend unlock instructions</h2>
2+
3+
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
4+
<%= devise_error_messages! %>
5+
6+
<div><%= f.label :email %><br />
7+
<%= f.email_field :email, :autofocus => true %></div>
8+
9+
<div><%= f.submit "Resend unlock instructions" %></div>
10+
<% end %>
11+
12+
<%= render "devise/shared/links" %>

app/views/layouts/application.html.erb

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
</div>
1818
</div>
1919
</div>
20+
<p class="notice"><%= notice %></p>
21+
<p class="alert"><%= alert %></p>
2022
<div class="container">
2123
<%= yield %>
2224
</div>

config/application.rb

+2
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,7 @@ class Application < Rails::Application
5858

5959
# Version of your assets, change this if you want to expire all your assets
6060
config.assets.version = '1.0'
61+
62+
config.assets.initialize_on_precompile = false
6163
end
6264
end

config/environments/development.rb

+2
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@
3434

3535
# Expands the lines which load the assets
3636
config.assets.debug = true
37+
38+
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
3739
end

0 commit comments

Comments
 (0)