Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # HTTP POST
- def create
- @user=User.new(params[:user])
- @user.new_password = true
- if @user.valid?
- begin
- if @user.save
- if $user.superuser?
- account = Account.find_by_code(params[:account_code])
- return( error_msg('new','Invalid Customer Account Code') ) if account.nil?
- end
- account = $user.accounts[0]
- @user.accounts << account
- @user.new_activation 'ADDUSER'
- render :action => 'show'
- else
- error_msg 'new', 'An error occurred saving this user'
- end
- rescue ActiveRecord::StatementInvalid => ex
- if ex.message =~ Regexp.new("Mysql::Error: Duplicate entry '#{@user.email_address}' for key")
- @user.errors.add :email_address, 'already exists.'
- error_msg 'new', 'A user with this email address already exists.'
- else
- raise ex
- end
- end
- else
- error_msg 'new', 'Invalid data'
- end
- end
- create_table "users", :force => true do |t|
- t.string "email_address", :limit => 128, :null => false
- t.string "salted_password", :limit => 40
- t.string "salt", :limit => 40
- t.string "forename", :limit => 64, :null => false
- t.string "surname", :limit => 64, :null => false
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "cookie_hash"
- t.boolean "superuser", :default => false
- t.boolean "administrator", :default => false
- end
- add_index "users", ["email_address"], :name => "index_users_on_email_address", :unique => true
- the model has loads of stuff in it but none that are of worth in this case
Add Comment
Please, Sign In to add comment