added user model

This commit is contained in:
Edin Dazdarevic
2015-02-20 06:55:18 +01:00
parent 7c27d9415a
commit 8f904099cf
6 changed files with 55 additions and 8 deletions

View File

@@ -0,0 +1,20 @@
get '/user/auth' do
# TODO: do something that makes sense here
res = User.find_by(id: 1).try(:authenticate, 'spassword') # => false
res.to_json
end
post '/user' do
request.body.rewind
json = request.body.read
user = User.new()
user.from_json(json, false)
if user.save
"ok"
else
status 400
user.errors.to_json
end
end