From 6436db926cadb2036e18a07f2357d2734a779cf4 Mon Sep 17 00:00:00 2001 From: Geoffrey Dagley Date: Mon, 24 Jun 2013 13:44:50 -0500 Subject: [PATCH] basic sign up/in/out with devise --- app/views/devise/confirmations/new.html.erb | 16 ++++++ .../mailer/confirmation_instructions.html.erb | 5 ++ .../reset_password_instructions.html.erb | 8 +++ .../mailer/unlock_instructions.html.erb | 7 +++ app/views/devise/passwords/edit.html.erb | 19 +++++++ app/views/devise/passwords/new.html.erb | 18 +++++++ app/views/devise/registrations/edit.html.erb | 21 ++++++++ app/views/devise/registrations/new.html.erb | 20 ++++++++ app/views/devise/sessions/new.html.erb | 20 ++++++++ app/views/devise/shared/_links.erb | 25 ++++++++++ app/views/devise/unlocks/new.html.erb | 16 ++++++ app/views/layouts/devise.html.erb | 50 +++++++++++++++++++ config/application.rb | 8 +++ 13 files changed, 233 insertions(+) create mode 100644 app/views/devise/confirmations/new.html.erb create mode 100644 app/views/devise/mailer/confirmation_instructions.html.erb create mode 100644 app/views/devise/mailer/reset_password_instructions.html.erb create mode 100644 app/views/devise/mailer/unlock_instructions.html.erb create mode 100644 app/views/devise/passwords/edit.html.erb create mode 100644 app/views/devise/passwords/new.html.erb create mode 100644 app/views/devise/registrations/edit.html.erb create mode 100644 app/views/devise/registrations/new.html.erb create mode 100644 app/views/devise/sessions/new.html.erb create mode 100644 app/views/devise/shared/_links.erb create mode 100644 app/views/devise/unlocks/new.html.erb create mode 100644 app/views/layouts/devise.html.erb diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb new file mode 100644 index 0000000..c80829a --- /dev/null +++ b/app/views/devise/confirmations/new.html.erb @@ -0,0 +1,16 @@ +

Resend confirmation instructions

+ +<%= simple_form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %> + <%= f.error_notification %> + <%= f.full_error :confirmation_token %> + +
+ <%= f.input :email, :required => true, :autofocus => true %> +
+ +
+ <%= f.button :submit, "Resend confirmation instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb new file mode 100644 index 0000000..5b04a72 --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -0,0 +1,5 @@ +

Welcome <%= @email %>!

+ +

You can confirm your account email through the link below:

+ +

<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>

diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..2713034 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +

Hello <%= @resource.email %>!

+ +

Someone has requested a link to change your password. You can do this through the link below.

+ +

<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>

+ +

If you didn't request this, please ignore this email.

+

Your password won't change until you access the link above and create a new one.

diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..a4152e1 --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +

Hello <%= @resource.email %>!

+ +

Your account has been locked due to an excessive number of unsuccessful sign in attempts.

+ +

Click the link below to unlock your account:

+ +

<%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %>

diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb new file mode 100644 index 0000000..5a2442a --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,19 @@ +

Change your password

+ +<%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %> + <%= f.error_notification %> + + <%= f.input :reset_password_token, :as => :hidden %> + <%= f.full_error :reset_password_token %> + +
+ <%= f.input :password, :label => "New password", :required => true, :autofocus => true %> + <%= f.input :password_confirmation, :label => "Confirm your new password", :required => true %> +
+ +
+ <%= f.button :submit, "Change my password" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb new file mode 100644 index 0000000..ed17cff --- /dev/null +++ b/app/views/devise/passwords/new.html.erb @@ -0,0 +1,18 @@ +

Forgot your password?

+ +<%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %> + <%= f.error_notification %> + +
+ <%= f.input :email, :required => true, :autofocus => true %> +
+ +
+ <%= f.button :submit, "Send me reset password instructions" %> + <%= link_to 'Cancel', root_url, :class => 'btn' %> +
+
+ <%= link_to "Sign in", new_session_path(resource_name) %> | + <%= link_to "Sign up", new_registration_path(resource_name) %> +
+<% end %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb new file mode 100644 index 0000000..aa754c6 --- /dev/null +++ b/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,21 @@ +

Edit My Account

+ +<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> + <%= f.error_notification %> + +
+ <%= f.input :email, :required => true, :autofocus => true %> + + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> +

Currently waiting confirmation for: <%= resource.unconfirmed_email %>

+ <% end %> + + <%= f.input :password, :autocomplete => "off", :hint => "leave it blank if you don't want to change it", :required => false %> + <%= f.input :password_confirmation, :required => false %> + <%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %> +
+ +
+ <%= f.button :submit, "Update", :class => 'btn btn-primary' %> +
+<% end %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb new file mode 100644 index 0000000..79681e8 --- /dev/null +++ b/app/views/devise/registrations/new.html.erb @@ -0,0 +1,20 @@ +

Sign up

+ +<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> + <%= f.error_notification %> + +
+ <%= f.input :email, :required => true, :autofocus => true %> + <%= f.input :password, :required => true %> + <%= f.input :password_confirmation, :required => true %> +
+ +
+ <%= f.button :submit, 'Sign up', :class => 'btn btn-primary' %> + <%= link_to 'Cancel', root_url, :class => 'btn' %> +
+
+ <%= link_to "Sign in", new_session_path(resource_name) %> | + <%= link_to "Forgot your password?", new_password_path(resource_name) %> +
+<% end %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb new file mode 100644 index 0000000..fa679ed --- /dev/null +++ b/app/views/devise/sessions/new.html.erb @@ -0,0 +1,20 @@ +

Sign in

+ +<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> +
+ <%= f.input :email, :required => false, :autofocus => true %> + <%= f.input :password, :required => false %> + <%= f.input :remember_me, :as => :boolean, :item_wrapper_class => 'inline' if devise_mapping.rememberable? %> +
+ +
+ <%= f.button :submit, "Sign in", :class => 'btn btn-primary' %> + <%= link_to 'Cancel', root_url, :class => 'btn' %> +
+ +
+ <%= link_to "Sign up", new_registration_path(resource_name) %> | + <%= link_to "Forgot your password?", new_password_path(resource_name) %> +
+ +<% end %> diff --git a/app/views/devise/shared/_links.erb b/app/views/devise/shared/_links.erb new file mode 100644 index 0000000..eab783a --- /dev/null +++ b/app/views/devise/shared/_links.erb @@ -0,0 +1,25 @@ +<%- if controller_name != 'sessions' %> + <%= link_to "Sign in", new_session_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.recoverable? && controller_name != 'passwords' %> + <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> + <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> + <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
+ <% end -%> +<% end -%> \ No newline at end of file diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb new file mode 100644 index 0000000..66495d6 --- /dev/null +++ b/app/views/devise/unlocks/new.html.erb @@ -0,0 +1,16 @@ +

Resend unlock instructions

+ +<%= simple_form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %> + <%= f.error_notification %> + <%= f.full_error :unlock_token %> + +
+ <%= f.input :email, :required => true, :autofocus => true %> +
+ +
+ <%= f.button :submit, "Resend unlock instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/layouts/devise.html.erb b/app/views/layouts/devise.html.erb new file mode 100644 index 0000000..77c1766 --- /dev/null +++ b/app/views/layouts/devise.html.erb @@ -0,0 +1,50 @@ + + + + + + <%= content_for?(:title) ? yield(:title) : "BaseJumper" %> + <%= csrf_meta_tags %> + + + + + <%= stylesheet_link_tag "application", :media => "all" %> + + + + + + <%= render 'shared/navbar' %> + +
+ <%= render 'shared/flash_messages' %> +
+
+
+
+ <%= yield %> +
+
+
+
+ +
+

© Company 2012

+
+
+ + + + + + <%= javascript_include_tag "application" %> + + + diff --git a/config/application.rb b/config/application.rb index 09aeefe..ae61163 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,6 +23,14 @@ class Application < Rails::Application # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + config.to_prepare do + Devise::SessionsController.layout "devise" + Devise::RegistrationsController.layout proc{ |controller| user_signed_in? ? "application" : "devise" } + Devise::ConfirmationsController.layout "devise" + Devise::UnlocksController.layout "devise" + Devise::PasswordsController.layout "devise" + end + # Custom directories with classes and modules you want to be autoloadable. # config.autoload_paths += %W(#{config.root}/extras)