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



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/contour/registrations_controller.rb', line 4

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