Sha256: 7e847617e97b7fe4ba552a786195b21b84dc711813efd720d79a140d1f1dc479

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

class OpenStax::Connect::Dev::UsersCreate
  include Lev::Handler

protected

  def setup
  end

  def authorized?
    !Rails.env.production?
  end

  def exec
    u = User.create do |user|
      user.first_name = params[:register][:first_name]
      user.last_name = params[:register][:last_name]
      user.username = params[:register][:username]
      user.is_administrator = params[:register][:is_administrator]
      user.openstax_uid = available_openstax_uid
    end
  
    transfer_errors_from(u, :register)

    results[:user] = u
  end

  def available_openstax_uid
    (User.order("openstax_uid DESC").first.try(:openstax_uid) || 0) + 1
  end

end 

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openstax_connect-0.0.2 app/handlers/openstax/connect/dev/users_create.rb
openstax_connect-0.0.1 app/handlers/openstax/connect/dev/users_create.rb