diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 1f15cf0..6e1dfbe 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -1,10 +1,34 @@
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
diff --git a/app/views/user/complete.erb b/app/views/user/complete.erb
new file mode 100644
index 0000000..c074972
--- /dev/null
+++ b/app/views/user/complete.erb
@@ -0,0 +1,3 @@
+
+
Welcome aboard, friend!
+
\ No newline at end of file
diff --git a/app/views/user/register.erb b/app/views/user/register.erb
new file mode 100644
index 0000000..34b238e
--- /dev/null
+++ b/app/views/user/register.erb
@@ -0,0 +1,31 @@
+
+
Greetings from BeatHaven!
+ <%= form_tag('/reg/complete', :method => 'post') do -%>
+ <%= hidden_field_tag 'invite_code', @code %>
+ <%= hidden_field_tag 'invite_email', @email %>
+ <%= label_tag 'email', 'E-mail' %><%= email_field_tag 'email', @email %>
+ <%= label_tag 'password', 'Password' %><%= password_field_tag 'password', nil %>
+ <%= label_tag 'password_c', 'Confirm' %><%= password_field_tag 'password_c', nil %>
+
+ <%= submit_tag 'Complete' %>
+
+ <% end -%>
+
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 762e860..a53adb2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -7,7 +7,9 @@ Beathaven::Application.routes.draw do
match 'listen/:id' => 'track#listen'
match 'search/autocomplete' => 'artist#autocomplete'
+ # Registration & login
match 'reg/:email/:code' => 'user#register', :constraints => { :email => /[-a-z0-9\._@]+/i, :code => /[a-z0-9]{8}/ }
+ match 'reg/complete' => 'user#complete'
match '*a', :to => 'errors#routing'
end
diff --git a/public/stylesheets/register.css b/public/stylesheets/register.css
new file mode 100644
index 0000000..dbe78a5
--- /dev/null
+++ b/public/stylesheets/register.css
@@ -0,0 +1,54 @@
+#registration {
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ margin: -145px 0 0 -195px;
+ padding: 20px;
+ width: 350px;
+ height: 250px;
+ background-color: #FFF;
+}
+ #registration h1 {
+ width: 100%;
+ text-align: center;
+ font-size: 28px;
+ font-weight: normal;
+ margin: 0 0 30px 0;
+ }
+
+ #registration label {
+ display: block;
+ float: left;
+ width: 100px;
+ font-size: 20px;
+ line-height: 35px;
+ }
+ #registration input[type="email"], input[type="password"] {
+ width: 230px;
+ font-size: 20px;
+ border: #EAEAEA 1px solid;
+ background-color: #FCFCFC;
+ padding: 5px;
+ }
+ #registration input[type="submit"] {
+ color: #FFF;
+ border: #EAEAEA 1px solid;
+ background-color: #05A;
+ font-size: 25px;
+ padding: 10px;
+ cursor: pointer;
+ }
+ #registration .complete {
+ width: 100%;
+ text-align: center;
+ margin-top: 20px;
+ }
+#email_error, #password_error, #password_c_error {
+ float: right;
+ color: #E30;
+ width: 350px;
+ height: 30px;
+ margin: 4px -350px 0 0;
+ line-height: 30px;
+ font-size: 15px;
+}
\ No newline at end of file