1
0
Fork 0
oldhaven/app/controllers/user_controller.rb

37 lines
1.0 KiB
Ruby
Raw Normal View History

2011-04-13 01:59:45 +00:00
class UserController < ApplicationController
def register
data = Invite.where(:email => params[:email], :code => params[:code]).first
unless data.nil?
@code = data.code
2011-04-13 03:34:56 +00:00
@email = data.email
else
redirect_to '/'
end
end
def complete
data = Invite.where(:email => params[:invite_email], :code => params[:invite_code]).first
unless data.nil?
if params[:email].match(/\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\z/).nil? or
params[:password].length < 6 or
params[:password] != params[:password_c]
redirect_to '/'
end
User.collection.insert({
email: params[:email],
password: Digest::SHA256.hexdigest(params[:password]),
name: '',
regdate: Time.now(),
referer: data.referer,
lastvisit: Time.now(),
invites: 0
})
Invite.collection.remove({email: params[:invite_email], code: params[:invite_code]})
2011-04-13 01:59:45 +00:00
else
redirect_to '/'
end
end
end