Sha256: 2fa81dc83951ebf16a6c0c4031943bb8606e616a5fdec459c4a1f2a30be093ff

Contents?: true

Size: 1.3 KB

Versions: 25

Compression:

Stored size: 1.3 KB

Contents

class Contour::RegistrationsController < Devise::RegistrationsController
  prepend_before_filter :require_no_authentication, only: [ :new ]

  def create
    if signed_in?
      # TODO: Should use "Resource" and not "User"
      params[:user][:password] = params[:user][:password_confirmation] = Digest::SHA1.hexdigest(Time.now.usec.to_s)[0..19] if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
      @user = User.new(params[:user])
      if @user.save
        respond_to do |format|
          format.html { redirect_to @user, notice: 'User was successfully created.' }
          format.json { render json: @user.as_json( only: [:id, :email, :first_name, :last_name, :authentication_token ] ), status: :created, location: @user }
        end
      else
        respond_to do |format|
          format.html { render action: "/users/new" }
          format.json { render json: @user.errors, status: :unprocessable_entity}
        end
      end
    else
      super
      session[:omniauth] = nil unless @user.new_record?
    end
  end

  private

  def build_resource(*args)
    super
    if session[:omniauth]
      @user.apply_omniauth(session[:omniauth])
      @user.valid?
    end
  end

  def after_inactive_sign_up_path_for(resource)
    new_session_path(resource) # root_path
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
contour-2.0.0.beta.3 app/controllers/contour/registrations_controller.rb
contour-2.0.0.beta.2 app/controllers/contour/registrations_controller.rb
contour-2.0.0.beta.1 app/controllers/contour/registrations_controller.rb
contour-1.3.0 app/controllers/contour/registrations_controller.rb
contour-1.3.0.pre app/controllers/contour/registrations_controller.rb
contour-1.2.1 app/controllers/contour/registrations_controller.rb
contour-1.2.0 app/controllers/contour/registrations_controller.rb
contour-1.2.0.pre8 app/controllers/contour/registrations_controller.rb
contour-1.2.0.pre7 app/controllers/contour/registrations_controller.rb
contour-1.2.0.pre6 app/controllers/contour/registrations_controller.rb
contour-1.2.0.pre5 app/controllers/contour/registrations_controller.rb
contour-1.2.0.pre4 app/controllers/contour/registrations_controller.rb
contour-1.2.0.pre3 app/controllers/contour/registrations_controller.rb
contour-1.2.0.pre2 app/controllers/contour/registrations_controller.rb
contour-1.1.3 app/controllers/contour/registrations_controller.rb
contour-1.2.0.pre app/controllers/contour/registrations_controller.rb
contour-1.1.3.pre2 app/controllers/contour/registrations_controller.rb
contour-1.1.3.pre app/controllers/contour/registrations_controller.rb
contour-1.1.2 app/controllers/contour/registrations_controller.rb
contour-1.1.2.pre2 app/controllers/contour/registrations_controller.rb