Skip to content

Commit 1cf0ffe

Browse files
committed
set devise to use usernames
1 parent 5820aa1 commit 1cf0ffe

13 files changed

Lines changed: 170 additions & 4 deletions

File tree

app/models/user.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class User
55
devise :database_authenticatable, :registerable,
66
:recoverable, :rememberable, :trackable, :validatable
77

8-
8+
key :username, String
9+
key :email, String
910

1011
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h2>Resend confirmation instructions</h2>
2+
3+
<%= simple_form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
4+
<%= f.error_notification %>
5+
6+
<div class="inputs">
7+
<%= f.input :email, :required => true %>
8+
</div>
9+
10+
<div class="actions">
11+
<%= f.button :submit, "Resend confirmation instructions" %>
12+
</div>
13+
<% end %>
14+
15+
<%= render :partial => "devise/shared/links" %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p>Welcome <%= @resource.email %>!</p>
2+
3+
<p>You can confirm your account through the link below:</p>
4+
5+
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
Lines changed: 8 additions & 0 deletions
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, and 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>
Lines changed: 7 additions & 0 deletions
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 amount 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>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<h2>Change your password</h2>
2+
3+
<%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
4+
<%= f.error_notification %>
5+
6+
<%= f.input :reset_password_token, :as => :hidden %>
7+
<%= f.full_error :reset_password_token %>
8+
9+
<div class="inputs">
10+
<%= f.input :password, :label => "New password", :required => true %>
11+
<%= f.input :password_confirmation, :label => "Confirm your new password", :required => true %>
12+
</div>
13+
14+
<div class="actions">
15+
<%= f.button :submit, "Change my password" %>
16+
</div>
17+
<% end %>
18+
19+
<%= render :partial => "devise/shared/links" %>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h2>Forgot your password?</h2>
2+
3+
<%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
4+
<%= f.error_notification %>
5+
6+
<div class="inputs">
7+
<%= f.input :email, :required => true %>
8+
</div>
9+
10+
<div class="actions">
11+
<%= f.button :submit, "Send me reset password instructions" %>
12+
</div>
13+
<% end %>
14+
15+
<%= render :partial => "devise/shared/links" %>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<h2>Edit <%= resource_name.to_s.humanize %></h2>
2+
3+
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4+
<%= f.error_notification %>
5+
6+
<div class="inputs">
7+
<%= f.input :username, :autofocus => true %>
8+
<%= f.input :email, :autofocus => true %>
9+
<%= f.input :password, :hint => "leave it blank if you don't want to change it", :required => false %>
10+
<%= f.input :password_confirmation, :required => false %>
11+
<%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %>
12+
</div>
13+
14+
<div class="actions">
15+
<%= f.button :submit, "Update" %>
16+
</div>
17+
<% end %>
18+
19+
<h3>Cancel my account</h3>
20+
21+
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
22+
23+
<%= link_to "Back", :back %>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<h2>Sign up</h2>
2+
3+
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
4+
<%= f.error_notification %>
5+
6+
<div class="inputs">
7+
<%= f.input :username, :autofocus => true %>
8+
<%= f.input :email %>
9+
<%= f.input :password %>
10+
<%= f.input :password_confirmation %>
11+
</div>
12+
13+
<div class="actions">
14+
<%= f.button :submit, "Sign up" %>
15+
</div>
16+
<% end %>
17+
18+
<%= render :partial => "devise/shared/links" %>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h2>Sign in</h2>
2+
3+
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
4+
<div class="inputs">
5+
<%= f.input :username, :required => false, :autofocus => true %>
6+
<%= f.input :password, :required => false %>
7+
<%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
8+
</div>
9+
10+
<div class="actions">
11+
<%= f.button :submit, "Sign in" %>
12+
</div>
13+
<% end %>
14+
15+
<%= render :partial => "devise/shared/links" %>

0 commit comments

Comments
 (0)