socialforge/app/api/mobile/apis/users.rb

31 lines
796 B
Ruby

module Mobile
class Users < Grape::API
resource :users do
desc "get all users"
get do
['hello']
end
desc "add a user"
params do
requires :login, type: String, desc: 'username'
requires :mail, type: String, desc: 'mail'
requires :password, type: String, desc: 'password'
end
post do
us = UsersService.new
begin
user = us.register params.merge(:password_confirmation => params[:password],
:should_confirmation_password => true)
raise "register failed #{user.errors.full_messages}" if user.new_record?
{status: 0, data: user}
rescue => e
{status: 1, message: e.message}
end
end
end
end
end