class RegistrationsController < Devise::RegistrationsController

  def update ## see https://github.com/plataformatec/devise/wiki/How-To%3a-Allow-users-to-edit-their-account-without-providing-a-password
    if resource.update_attributes(team_parameters)
      set_flash_message :notice, :updated
      # Line below required if using Devise >= 1.2.0
      sign_in resource_name, resource, :bypass => true
      redirect_to after_update_path_for(resource)
    else
      clean_up_passwords(resource)
      render_with_scope :edit
    end
  end

  def new
    super
    resource.zverejnit_jmena = true
  end
  
  def destroy
    render html: 'Pokud se chcete odhlásit ze Čtyřpoháru, kontaktujte nás na 4p@hrejsi.cz'
  end

protected
  def after_sign_in_path_for(resource_or_scope)
    flash[:notice] = flash[:notice].to_s+'Již jste registováni, zde můžete upravit své údaje.'
    '/teams/edit'
  end

  def after_update_path_for(resource)
    '/teams/edit'
  end

  def after_sign_out_path_for(resource_or_scope)
    '/teams/sign_in'
  end

  def after_inactive_sign_up_path_for(resource)
    '/teams/mailsent'
  end

  def after_sign_up_path_for(resource)
    'xxxxxxxxxsignup/teams/mailsent'
  end

  private
  def team_parameters
    params.require(:team).permit(Team.allowed_params)
  end
end
