def reset_password
    email = params[:session] && params[:session][:email]
    credential = Credentials::Email.with email

    if user = (credential && credential.user)
      token = Tokens::PasswordReset.random_for user
      email = ::SessionMailer.reset_password_email(email, token, root_url)
      # TODO(pwnall): fix the serialization errors blocking deliver_later
      email.deliver_now
    end

    respond_to do |format|
      if user
        format.html do
          redirect_to new_session_url, alert:
              'Please check your e-mail for instructions'
        end
        format.json { render json: { } }
      else
        error_text = 'Invalid e-mail'
        format.html do
          redirect_to new_session_url, alert: error_text
        end
        format.json do
          render json: { error: :not_found, text: notice }
        end
      end
    end
  end
def reset_password
    email = params[:session] && params[:session][:email]
    credential = Credentials::Email.with email

    if user = (credential && credential.user)
      token = Tokens::PasswordReset.random_for user
      email = ::SessionMailer.reset_password_email(email, token, root_url)
      # TODO(pwnall): fix the serialization errors blocking deliver_later
      email.deliver_now
    end

    respond_to do |format|
      if user
        format.html do
          redirect_to new_session_url, alert:
              'Please check your e-mail for instructions'
        end
        format.json { render json: { } }
      else
        error_text = 'Invalid e-mail'
        format.html do
          redirect_to new_session_url, alert: error_text
        end
        format.json do
          render json: { error: :not_found, text: notice }
        end
      end
    end
  end
POST /session/reset_password