getting_started_controller.rb 917 B

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