Skip to content

Commit d3227a0

Browse files
committed
installing devise gem and configure it
1 parent 9b4f649 commit d3227a0

26 files changed

+699
-1
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ gem 'jbuilder', '~> 2.5'
3131
# gem 'bcrypt', '~> 3.1.7'
3232
gem 'jquery-rails', '~> 4.3', '>= 4.3.3'
3333
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
34-
34+
gem 'devise', '~> 4.4', '>= 4.4.3'
3535
# Use Capistrano for deployment
3636
# gem 'capistrano-rails', group: :development
3737

Gemfile.lock

+14
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ GEM
4343
arel (8.0.0)
4444
autoprefixer-rails (8.4.1)
4545
execjs
46+
bcrypt (3.1.12-x86-mingw32)
4647
bindex (0.5.0)
4748
bootstrap-sass (3.3.7)
4849
autoprefixer-rails (>= 5.2.1)
@@ -67,6 +68,12 @@ GEM
6768
coffee-script-source (1.12.2)
6869
concurrent-ruby (1.0.5)
6970
crass (1.0.4)
71+
devise (4.4.3)
72+
bcrypt (~> 3.0)
73+
orm_adapter (~> 0.1)
74+
railties (>= 4.1.0, < 6.0)
75+
responders
76+
warden (~> 1.2.3)
7077
erubi (1.7.1)
7178
execjs (2.7.0)
7279
ffi (1.9.23-x86-mingw32)
@@ -94,6 +101,7 @@ GEM
94101
nio4r (2.3.1)
95102
nokogiri (1.8.2-x86-mingw32)
96103
mini_portile2 (~> 2.3.0)
104+
orm_adapter (0.5.0)
97105
public_suffix (3.0.2)
98106
puma (3.11.4)
99107
rack (2.0.5)
@@ -126,6 +134,9 @@ GEM
126134
rb-fsevent (0.10.3)
127135
rb-inotify (0.9.10)
128136
ffi (>= 0.5.0, < 2)
137+
responders (2.4.0)
138+
actionpack (>= 4.2.0, < 5.3)
139+
railties (>= 4.2.0, < 5.3)
129140
rubyzip (1.2.1)
130141
sass (3.5.6)
131142
sass-listen (~> 4.0.0)
@@ -161,6 +172,8 @@ GEM
161172
tzinfo (>= 1.0.0)
162173
uglifier (4.1.10)
163174
execjs (>= 0.3.0, < 3)
175+
warden (1.2.7)
176+
rack (>= 1.0)
164177
web-console (3.6.2)
165178
actionview (>= 5.0)
166179
activemodel (>= 5.0)
@@ -180,6 +193,7 @@ DEPENDENCIES
180193
byebug
181194
capybara (~> 2.13)
182195
coffee-rails (~> 4.2)
196+
devise (~> 4.4, >= 4.4.3)
183197
jbuilder (~> 2.5)
184198
jquery-rails (~> 4.3, >= 4.3.3)
185199
puma (~> 3.7)

app/models/user.rb

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class User < ApplicationRecord
2+
# Include default devise modules. Others available are:
3+
# :confirmable, :lockable, :timeoutable and :omniauthable
4+
devise :database_authenticatable, :registerable,
5+
:recoverable, :rememberable, :trackable, :validatable
6+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 class="field">
7+
<%= f.label :email %><br />
8+
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
9+
</div>
10+
11+
<div class="actions">
12+
<%= f.submit "Resend confirmation instructions" %>
13+
</div>
14+
<% end %>
15+
16+
<%= 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: @token) %></p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p>Hello <%= @email %>!</p>
2+
3+
<% if @resource.try(:unconfirmed_email?) %>
4+
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
5+
<% else %>
6+
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
7+
<% end %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>Hello <%= @resource.email %>!</p>
2+
3+
<p>We're contacting you to notify you that your password has been changed.</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: @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: @token) %></p>
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 class="field">
8+
<%= f.label :password, "New password" %><br />
9+
<% if @minimum_password_length %>
10+
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
11+
<% end %>
12+
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
13+
</div>
14+
15+
<div class="field">
16+
<%= f.label :password_confirmation, "Confirm new password" %><br />
17+
<%= f.password_field :password_confirmation, autocomplete: "off" %>
18+
</div>
19+
20+
<div class="actions">
21+
<%= f.submit "Change my password" %>
22+
</div>
23+
<% end %>
24+
25+
<%= render "devise/shared/links" %>
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 class="field">
7+
<%= f.label :email %><br />
8+
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
9+
</div>
10+
11+
<div class="actions">
12+
<%= f.submit "Send me reset password instructions" %>
13+
</div>
14+
<% end %>
15+
16+
<%= render "devise/shared/links" %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 class="field">
7+
<%= f.label :email %><br />
8+
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
9+
</div>
10+
11+
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
12+
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
13+
<% end %>
14+
15+
<div class="field">
16+
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
17+
<%= f.password_field :password, autocomplete: "off" %>
18+
<% if @minimum_password_length %>
19+
<br />
20+
<em><%= @minimum_password_length %> characters minimum</em>
21+
<% end %>
22+
</div>
23+
24+
<div class="field">
25+
<%= f.label :password_confirmation %><br />
26+
<%= f.password_field :password_confirmation, autocomplete: "off" %>
27+
</div>
28+
29+
<div class="field">
30+
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
31+
<%= f.password_field :current_password, autocomplete: "off" %>
32+
</div>
33+
34+
<div class="actions">
35+
<%= f.submit "Update" %>
36+
</div>
37+
<% end %>
38+
39+
<h3>Cancel my account</h3>
40+
41+
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
42+
43+
<%= link_to "Back", :back %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 class="field">
7+
<%= f.label :email %><br />
8+
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
9+
</div>
10+
11+
<div class="field">
12+
<%= f.label :password %>
13+
<% if @minimum_password_length %>
14+
<em>(<%= @minimum_password_length %> characters minimum)</em>
15+
<% end %><br />
16+
<%= f.password_field :password, autocomplete: "off" %>
17+
</div>
18+
19+
<div class="field">
20+
<%= f.label :password_confirmation %><br />
21+
<%= f.password_field :password_confirmation, autocomplete: "off" %>
22+
</div>
23+
24+
<div class="actions">
25+
<%= f.submit "Sign up" %>
26+
</div>
27+
<% end %>
28+
29+
<%= render "devise/shared/links" %>
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<h2>Log in</h2>
2+
3+
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4+
<div class="field">
5+
<%= f.label :email %><br />
6+
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
7+
</div>
8+
9+
<div class="field">
10+
<%= f.label :password %><br />
11+
<%= f.password_field :password, autocomplete: "off" %>
12+
</div>
13+
14+
<% if devise_mapping.rememberable? -%>
15+
<div class="field">
16+
<%= f.check_box :remember_me %>
17+
<%= f.label :remember_me %>
18+
</div>
19+
<% end -%>
20+
21+
<div class="actions">
22+
<%= f.submit "Log in" %>
23+
</div>
24+
<% end %>
25+
26+
<%= render "devise/shared/links" %>
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<%- if controller_name != 'sessions' %>
2+
<%= link_to "Log 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' && controller_name != 'registrations' %>
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 #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
24+
<% end -%>
25+
<% end -%>

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

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 class="field">
7+
<%= f.label :email %><br />
8+
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
9+
</div>
10+
11+
<div class="actions">
12+
<%= f.submit "Resend unlock instructions" %>
13+
</div>
14+
<% end %>
15+
16+
<%= render "devise/shared/links" %>

app/views/home/_flash.html.erb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<% flash.each do |name,msg| %>
2+
<div class="alert alert-warning alert-dismissible">
3+
<button class="close" data-dismiss="alert">
4+
<i class="glyphicon glyphicon-remove-circle"></i>
5+
</button>
6+
<%= content_tag(:div, msg)%>
7+
</div>
8+
<% end %>

app/views/layouts/application.html.erb

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<body>
1313
<%= render 'home/navbar' %>
1414
<div class="container">
15+
<%= render 'home/flash' %>
1516
<%= yield %>
1617
</div>
1718
</body>

config/environments/development.rb

+1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@
5151
# Use an evented file watcher to asynchronously detect changes in source code,
5252
# routes, locales, etc. This feature depends on the listen gem.
5353
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
54+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
5455
end

0 commit comments

Comments
 (0)