Skip to content

Commit acade12

Browse files
author
Ryan Bigg
committed
Section 6.3.1: Styled sign up and sign in forms
1 parent c0855a8 commit acade12

File tree

11 files changed

+170
-0
lines changed

11 files changed

+170
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
<%= f.full_error :confirmation_token %>
6+
7+
<div class="form-inputs">
8+
<%= f.input :email, required: true, autofocus: true %>
9+
</div>
10+
11+
<div class="form-actions">
12+
<%= f.button :submit, "Resend confirmation instructions" %>
13+
</div>
14+
<% end %>
15+
16+
<%= render "devise/shared/links" %>
Lines changed: 5 additions & 0 deletions
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>
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. 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>
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 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>
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="form-inputs">
10+
<%= f.input :password, label: "New password", required: true, autofocus: true %>
11+
<%= f.input :password_confirmation, label: "Confirm your new password", required: true %>
12+
</div>
13+
14+
<div class="form-actions">
15+
<%= f.button :submit, "Change my password" %>
16+
</div>
17+
<% end %>
18+
19+
<%= render "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="form-inputs">
7+
<%= f.input :email, required: true, autofocus: true %>
8+
</div>
9+
10+
<div class="form-actions">
11+
<%= f.button :submit, "Send me reset password instructions" %>
12+
</div>
13+
<% end %>
14+
15+
<%= render "devise/shared/links" %>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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="form-inputs">
7+
<%= f.input :email, required: true, autofocus: true %>
8+
9+
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
10+
<p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
11+
<% end %>
12+
13+
<%= f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false %>
14+
<%= f.input :password_confirmation, required: false %>
15+
<%= f.input :current_password, hint: "we need your current password to confirm your changes", required: true %>
16+
</div>
17+
18+
<div class="form-actions">
19+
<%= f.button :submit, "Update" %>
20+
</div>
21+
<% end %>
22+
23+
<h3>Cancel my account</h3>
24+
25+
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
26+
27+
<%= link_to "Back", :back %>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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="form-inputs">
7+
<%= f.input :email, required: true, autofocus: true %>
8+
<%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @validatable) %>
9+
<%= f.input :password_confirmation, required: true %>
10+
</div>
11+
12+
<div class="form-actions">
13+
<%= f.button :submit, "Sign up", class: "btn btn-primary" %>
14+
</div>
15+
<% end %>
16+
17+
<%= render "devise/shared/links" %>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h2>Log in</h2>
2+
3+
<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4+
<div class="form-inputs">
5+
<%= f.input :email, 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="form-actions">
11+
<%= f.button :submit, "Log in", class: "btn btn-primary" %>
12+
</div>
13+
<% end %>
14+
15+
<%= render "devise/shared/links" %>
Lines changed: 25 additions & 0 deletions
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 #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
24+
<% end -%>
25+
<% end -%>

0 commit comments

Comments
 (0)