2014-11-27 19:43:04 +08:00
|
|
|
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 :email, type: String, desc: 'email'
|
|
|
|
requires :password, type: String, desc: 'password'
|
|
|
|
end
|
|
|
|
post do
|
|
|
|
user = User.new
|
|
|
|
user.login = params[:login]
|
2014-12-03 17:28:19 +08:00
|
|
|
user.mail = params[:mail]
|
2014-11-27 19:43:04 +08:00
|
|
|
user.password = params[:password]
|
|
|
|
user.password_confirmation = params[:password]
|
|
|
|
user.activate
|
|
|
|
if user.save!
|
2014-12-03 17:28:19 +08:00
|
|
|
UserStatus.create(:user_id => user.id, :changsets_course => 0, :watchers_count => 0)
|
2014-11-27 19:43:04 +08:00
|
|
|
end
|
|
|
|
user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|