Class: Contour::RegistrationsController

Inherits:
Devise::RegistrationsController
  • Object
show all
Defined in:
app/controllers/contour/registrations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/contour/registrations_controller.rb', line 5

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?

    # self.resource = build_resource
    @user = build_resource

    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, :authentication_token ] | Contour::.collect{|a| a[:attribute].to_sym}) ), 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
  elsif spam_field_used?
    Rails.logger.info "SPAM BOT SIGNUP: #{params.inspect}"
    self.resource = build_resource
    redirect_to new_session_path(resource), notice: 'Thank you for your interest! Due to limited capacity you have been put on a waiting list. We will email you when we open up additional space.'
  else
    super
    # session[:omniauth] = nil if @user and not @user.new_record?
  end
end