class UserController < ApplicationController def register data = Invite.where(:email => params[:email], :code => params[:code]).first unless data.nil? @code = data.code @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]}) else redirect_to '/' end end end