Sha256: 51ade3f915cd37bff9283e4382ad31c615908aa74c81132eb0ff67a33e78d791

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

class Authentifyd::RegistrationsController < Devise::RegistrationsController
  include Localyzed::LocalyzedController
  helper Authentifyd::ApplicationHelper

  layout "authentifyd/application"
  before_filter :define_body_class
  
  def new
    # Building the resource with information that MAY BE available from omniauth!
    build_resource(:email => session[:omniauth_email])
    render :new
  end

  def create
    build_resource

    if session[:omniauth] && @user.errors[:email][0] =~ /has already been taken/
      user = Authentifyd::User.find_by_email(@user.email)
      # Link Accounts - if via social connect
      return redirect_to link_accounts_url(user.id)
    end

    # normal processing
    super
    session[:omniauth] = nil unless @user.new_record?
  end

  def build_resource(*args)
    super

    if session[:omniauth]
      @user.apply_omniauth(session[:omniauth])
      @user.valid?
    end
  end
  
  private
  
  def define_body_class
    @body_class = "authentifyd_registrations_#{action_name}"
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
authentifyd-0.0.13 app/controllers/authentifyd/registrations_controller.rb
authentifyd-0.0.12 app/controllers/authentifyd/registrations_controller.rb