Skip to content

Commit 9569f59

Browse files
committed
Adding signup via the API.
1 parent e747e2f commit 9569f59

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

controllers/sessions_controller.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,28 @@
6666
# by the desktop app to see if you've entered correct information.
6767
post '/check_credentials' do
6868
#let's see if we got a correct username/password:
69-
puts "username: #{params[:username]} / #{params[:password]}"
7069
if Hacker.authenticate(params[:username], params[:password])
7170
"Success"
7271
else
7372
halt 401
7473
end
7574
end
75+
76+
# This method will let people sign up from within the app. Frankly this is
77+
# a really bad way to do it, but I'm not sure what the best way is. It should
78+
# be combined with the signup method above. The issue is that signup via the
79+
# API should really just throw the message rather than redirect, but the site
80+
# should redirect. This probably should be managed via content negotiation. I'm
81+
# doing it the dirty way now, and when I look at exposing a Real Api I'll worry
82+
# about making it 100% nice.
83+
post '/signup_via_api' do
84+
@hacker = Hacker.create(:username => params[:username],
85+
:email => params[:email],
86+
:password => params[:password])
87+
88+
if @hacker && @hacker.valid?
89+
"Success"
90+
else
91+
404 #is this right?
92+
end
93+
end

0 commit comments

Comments
 (0)