Sha256: d57b2f90ca5fba30af89f88f53fcfdd6c125dca37db80c22f1a0a85e399994fe

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 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
  
  alias_method :orig_after_inactive_sign_up_path_for, :after_inactive_sign_up_path_for
  def after_inactive_sign_up_path_for resource_or_scope
    new_user_session_url || orig_after_sign_up_path_for
  end
  
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
authentifyd-0.1.0.2 app/controllers/authentifyd/registrations_controller.rb
authentifyd-0.1.0.1 app/controllers/authentifyd/registrations_controller.rb
authentifyd-0.1.0 app/controllers/authentifyd/registrations_controller.rb
authentifyd-0.0.16 app/controllers/authentifyd/registrations_controller.rb
authentifyd-0.0.15 app/controllers/authentifyd/registrations_controller.rb
authentifyd-0.0.14 app/controllers/authentifyd/registrations_controller.rb