Sha256: 1a5248c7f0032840845e56bbf5d3b38229ef6e38efaaee55ef0c74612962a45c

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

class Iugu::ProfileController < Iugu::SettingsController
  
  def index
    @user = current_user
    @social_accounts = @user.social_accounts
    render 'iugu/settings/profile'
  end

  def update
    @user = current_user
    @social_accounts = @user.social_accounts
    if @user.update_attributes(params[:user])
      flash[:notice] = I18n.t('iugu.notices.user_update')
    else
      flash[:error] = @user.errors.full_messages
    end
    render 'iugu/settings/profile'
  end

  def destroy
    (user = current_user).destroy
    redirect_to(profile_settings_path, :notice => I18n.t("iugu.user_destruction_in") + user.destruction_job.run_at.to_s)
  end

  def cancel_destruction
    current_user.cancel_destruction
    redirect_to(profile_settings_path, :notice => I18n.t("iugu.user_destruction_undone"))
  end

  def destroy_social
    begin
      if social_account = current_user.social_accounts.where(:id => params[:id]).first.unlink
        notice = I18n.t("iugu.social_unlinked")
      else
        notice = I18n.t("errors.messages.only_social_and_no_email")
      end
    rescue
      notice = I18n.t("errors.messages.not_found")
    end
    flash[:social] = notice
    redirect_to profile_settings_path
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.2 app/controllers/iugu/profile_controller.rb
iugusdk-1.0.0.alpha.1 app/controllers/iugu/profile_controller.rb
iugusdk-1.0.0.alpha.0 app/controllers/iugu/profile_controller.rb