Sha256: 30e4fef9e7603f606849a6c3e05f3fe1b7c825c587796f2c370553121459fb9d

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

class Devise::CertificationsController < ApplicationController
  include Devise::Controllers::InternalHelpers
  before_filter :authenticate_certifier!
  
  # GET /resource/certification/edit?certification_token=abcdef
  def edit
    self.resource = resource_class.find_resource_by_token(params[:certification_token])
    
    if resource.errors.empty?
      render_with_scope :edit
    else
      set_flash_message(:alert, :certification_token_invalid)
      redirect_to self.resource
    end
  end

  # PUT /resource/certification
  def update
    self.resource = resource_class.certify_by_token(params[resource_name][:certification_token], current_certifier)
    params[resource_name].delete(:certification_token)
    self.resource.update_attributes(params[resource_name])
    if resource.errors.empty?
      set_flash_message :notice, :certified
      redirect_to self.resource
    else
      render_with_scope :edit
    end
  end

  protected
  def current_certifier
    current_user
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise_certifiable-0.1.0 app/controllers/devise/certifications_controller.rb