Permalink
Browse files

User creation is now working.

  • Loading branch information...
1 parent 4888719 commit 731a7b8a754758b891b6aaa0cbf2443ed59f8297 Randall B committed Jul 9, 2010
Showing with 15 additions and 9 deletions.
  1. +1 −1 COPYING
  2. +14 −8 lib/boardwalk/control_routes.rb
View
2 COPYING
@@ -1,4 +1,4 @@
-Sinatra port as well as changes (c) 2010 Randall Brewer
+Overhaul/ported code (c) 2010 Randall Brewer
Original coding/concept copyright (c) 2006 why the lucky stiff
Permission is hereby granted, free of charge, to any person obtaining a copy
View
22 lib/boardwalk/control_routes.rb
@@ -141,16 +141,13 @@
get '/control/users' do
login_required
only_superusers
- # Don't understand the need for this. I assume it's for a new user form in
- # the view.
@usero = User.new
# Find all the users that aren't marked as deleted.
@users = User.all(:conditions => {'deleted' => false}) # <conditions>
@title = "User List"
haml :control_users
end
-=begin
# def post
# only_superusers
# @usero = User.new @input.user.merge(:activated_at => Time.now)
@@ -163,19 +160,28 @@
# end
post '/control/users' do
login_required
- superuser_required
- @usero = User.new # The stuff up top is to put the activation time in the
- # form (I think).
+ only_superusers
+ puts params.inspect
+ superuser = false
+ superuser = true if params[:superuser] == 'on'
+ throw :halt, [500, "Passwords did not match!"] if params[:password] != params[:password_confirmation]
+ @usero = User.create(:login => params[:login], :password => params[:password], :superuser => superuser, :email => params[:email], :s3key => params[:key], :s3secret => params[:secret], :created_at => Time.now)
+ @usero.password = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new("sha1"), @usero.password, @usero.s3secret)).strip
if @usero.valid?
- @usero.save
- redirect '/control/users'
+ if @usero.save
+ redirect '/control/users'
+ status 200
+ else
+ throw :halt, [500, "Error processing user."]
+ end
else
haml :control_user
end
end
# end
##
+=begin
##
# class CDeleteUser < R '/control/users/delete/(.+)'
# login_required

0 comments on commit 731a7b8

Please sign in to comment.