getting_started_controller.rb 835 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. class GettingStartedController < ApplicationController
  2. =begin
  3. Resource:
  4. GET /api/getting_started.json
  5. Response:
  6. {
  7. "master_user": 1,
  8. "groups": [
  9. {
  10. "name": "group1",
  11. "active":true
  12. },
  13. {
  14. "name": "group2",
  15. "active":true
  16. }
  17. ]
  18. }
  19. Test:
  20. curl http://localhost/api/getting_started.json -v -u #{login}:#{password}
  21. =end
  22. def index
  23. # check if first user already exists
  24. master_user = 0
  25. count = User.all.count()
  26. if count <= 2
  27. master_user = 1
  28. end
  29. # if master user already exists, we need to be authenticated
  30. if master_user == 0
  31. return if !authentication_check
  32. end
  33. # get all groups
  34. groups = Group.where( :active => true )
  35. # return result
  36. render :json => {
  37. :master_user => master_user,
  38. :groups => groups,
  39. }
  40. end
  41. end