concordia-publishing-house/errbit

View on GitHub
app/views/devise/sessions/new.html.haml

Summary

Maintainability
Test Coverage
- content_for :title, 'Sign in'
- auth_key = Devise.authentication_keys.first

- if Errbit::Config.github_authentication
  - content_for :action_bar do
    %div.action-bar
      %span.github= link_to "Sign in with GitHub", user_omniauth_authorize_path(:github)

= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
  .required
    = f.label auth_key
    = f.text_field auth_key, :type => (Errbit::Config.user_has_username ? 'text' : 'email'), :tabindex => 1, :autofocus => true

  .required
    = link_to 'forget it?', new_password_path(resource_name), :class => 'float-right', :id => "forgot_password"
    = f.label :password
    = f.password_field :password, :tabindex => 2

  - if devise_mapping.rememberable?
    %div.checkbox
      = f.check_box :remember_me, :tabindex => 3
      = f.label :remember_me

  %div.buttons
    %button{:type => 'submit', :class => 'sign_in'}=t('.sign_in')

:javascript
  $('a#forgot_password').click(function(){
    // Set email field on password reset page to email that user entered on this page
    location.href = $(this).attr('href') + "?email=" + $('#user_#{auth_key}').val();
    return false;
  });