diff --git a/tracks/app/apis/todo_api.rb b/tracks/app/apis/todo_api.rb index 385a207f..584640ca 100644 --- a/tracks/app/apis/todo_api.rb +++ b/tracks/app/apis/todo_api.rb @@ -2,4 +2,13 @@ class TodoApi < ActionWebService::API::Base api_method :new_todo, :expects => [{:username => :string}, {:token => :string}, {:context_id => :int}, {:description => :string}], :returns => [:int] + + api_method :list_contexts, + :expects => [{:username => :string}, {:token => :string}], + :returns => [[Context]] + + api_method :list_projects, + :expects => [{:username => :string}, {:token => :string}], + :returns => [[Project]] + end diff --git a/tracks/app/controllers/backend_controller.rb b/tracks/app/controllers/backend_controller.rb index ee8fa802..6746bcca 100644 --- a/tracks/app/controllers/backend_controller.rb +++ b/tracks/app/controllers/backend_controller.rb @@ -16,6 +16,22 @@ class BackendController < ApplicationController item.id end + def list_contexts(username, token) + if !check_token_against_user_word(username, token) + raise "invalid token" + end + + @user.contexts + end + + def list_projects(username, token) + if !check_token_against_user_word(username, token) + raise "invalid token" + end + + @user.projects + end + protected # Check whether the token in the URL matches the word in the User's table