module UsersHelper
  def registration_form_for user, &proc
    devise_form_for :registration, user, &proc
  end

  def session_form_for user, &proc
    devise_form_for :session, user, &proc
  end

  def confirmation_form_for user, &proc
    devise_form_for :confirmation, user, &proc
  end

  def password_form_for user, &proc
    devise_form_for :password, user, &proc
  end

  def devise_form_for name, user, &proc
    url = nil
    eval "url = #{name}_path :user"
    html = { class: 'default' }
    form_for user, url: url, html: html, &proc
  end

  def session_form user
    partial 'users/sessions/form', user: user
  end

  def signup_link
    name = 'Sign up'
    path = new_registration_path :user
    link_to name, path
  end

  def signin_link
    name = 'Sign in'
    path = new_session_path :user
    link_to name, path
  end

  def forgot_link
    name = 'Forgot your password?'
    path = new_password_path :user
    link_to name, path
  end

  def confirm_link
    name = "Didn't receive confirmation instructions?"
    path = new_confirmation_path :user
    link_to name, path
  end
end