class UserController < BaseController
  authentication_required :except => [:new, :create, :vertify]
  renders_with_error_proc :below_field
  filter_parameter_logging :password

  layout 'simple'

  def new
    @user = User.new
  end

  def create
    @user = @site.users.build params[:user]
    if @site.save
      trigger_events @user, :registered
      render :action => 'verification_sent'
    else
      flash[:error] = t(:'adva.signup.flash.create.failure')
      render :action => :new
    end
  end

  def verification_sent
  end

  def verify
    if current_user.verify!
      trigger_events current_user, :verified
      flash[:notice] = t(:'adva.signup.flash.verify.success')
    else
      flash[:error] = t(:'adva.signup.flash.verify.failure')
    end
    redirect_to return_from(:verify)
  end

  def destroy
    current_user.destroy
    trigger_events current_user
    flash[:notice] = t(:'adva.signup.flash.destroy.success', :name =>  current_user.name)
    redirect_to '/'
  end

  private
    def url_with_token(user, purpose, params)
      token = user.assign_token purpose
      user.save
      url_for params.merge(:token => "#{user.id};#{token}")
    end
end

class UserController < BaseController
  authentication_required :except => [:new, :create]
  renders_with_error_proc :below_field
  filter_parameter_logging :password

  layout 'simple'

  def new
    @user = User.new
  end

  def create
    @user = @site.users.build params[:user]
    if @site.save
      trigger_events @user, :registered
      render :action => 'verification_sent'
    else
      flash[:error] = t(:'adva.signup.flash.create.failure')
      render :action => :new
    end
  end

  def verification_sent
  end

  def verify
    if current_user.verify!
      trigger_events current_user, :verified
      flash[:notice] = t(:'adva.signup.flash.verify.success')
    else
      flash[:error] = t(:'adva.signup.flash.verify.failure')
    end
    redirect_to return_from(:verify)
  end

  def destroy
    current_user.destroy
    trigger_events current_user
    flash[:notice] = t(:'adva.signup.flash.destroy.success', :name =>  current_user.name)
    redirect_to '/'
  end

  private
    def url_with_token(user, purpose, params)
      token = user.assign_token purpose
      user.save
      url_for params.merge(:token => "#{user.id};#{token}")
    end
end

Revert "user: vertify method was under authentication_required". Authentication is done via URL token and is needed for verification.
Revert "user: vertify method was under authentication_required". Authentication is done via URL token and is needed for verification.

This reverts commit 96b23c01b3c4f8cd0efa57868bab9ab5a2433beb.
