anchor.diff:                      NewU = OU#user{password=Md5NewPass},
                       Res = {struct, [{status, "ok"}]},
                       NewS = S#state{users=update_user(NewU, S#state.users)},
  -                    {Res, NewS};
  +                    {{Res, []}, NewS};
                   false ->
                       Res = {struct, [{status, "error"},
                                       {reason, "unknown user"}]},
  -                    {Res, S}
  +                    {{Res, []}, S}
               end;
           #user{} ->
               Res = {struct, [{status, "error"},
                               {reason, "only allowed for admin user"}]},
  -            {Res, S};
  +            {{Res,[]}, S};
           _ ->
               Res = {struct, [{status, "error"},
                               {reason, "unknown sid"}]},
  -            {Res, S}
  +            {{Res,[]}, S}
       end;
   %% http://idrott/idrott/get_all_users?sid=1234567890
  -do_cmd("get_all_users", L, _Json, S) ->
  -    Sid = get_val("sid", L, ""),
  +do_cmd("get_all_users", L, _Json, A, S) ->
  +    Sid = get_sid(A,L),
       case get_user_by_id(Sid, S) of
           #user{} ->
               %% login successful
  
positive.code:             Res = {struct, [{status, "error"},
                              {reason, "unknown sid"}]}
      end,
      {Res, NewS};
  
  %% http://idrott/idrott/set_user?sid=1234567890&foo=bar
  do_cmd("set_user", L, Json, S) ->
      Sid = get_val("sid", L, ""),
      case get_user_by_id(Sid, S) of
          U=#user{} ->
              %% login successful
              U2 = apply_user_ops(U,L),
              NewU = apply_user_json(U2, Json),
              Res = {struct, [{status, "ok"}]},
              {Res, S#state{users=update_user(NewU, S#state.users)}};
          _ ->
              Res = {struct, [{status, "error"},
                              {reason, "unknown sid"}]},
              {Res, S}
      end;
  %% http://idrott/idrott/set_user?sid=1234567890&foo=bar
  do_cmd("set_named_user", L, Json, S) ->
      Sid = get_val("sid", L, ""),
      case get_user_by_id(Sid, S) of
          U=#user{} when U#user.role == admin ->
              Username = get_val("username", L, ""),
  
negative.code:     end,
      Res = {struct, [{status, "ok"}]},
      save_data(NewData),
      {{Res,[]}, S#state{data=NewData}};
  do_cmd("delete", L, _Json, _A, S) ->
      Key = get_val("key", L, ""),
      case lists:keymember(Key, 1, S#state.data) of
          true ->
              NewData = lists:keydelete(Key, 1, S#state.data);
          false ->
              NewData = S#state.data
      end,
      Res = {struct, [{status, "ok"}]},
      save_data(NewData),
      {{Res,[]}, S#state{data=NewData}};
  do_cmd("get", L, _Json, _A, S) ->
      Key = get_val("key", L, ""),
      case lists:keysearch(Key, 1, S#state.data) of
          {value, {Key, Json}} ->
              Res = Json;
          false ->
              Res = {struct, [{status, "error"}, {reason, "unknown key"}]}
      end,
      {{Res,[]}, S};
  %% http://idrott/idrott/login?user=johan&password=test
  do_cmd("login", L, _Json, _A, S) ->
      User = get_val("user", L, ""),
      Password = get_val("password", L, ""),
      Remember = get_val("remember", L, "false"),
      Md5Pass = ?b2l(base64:encode(crypto:hash(md5, Password))),
      case get_user_by_name(User, S) of
          U=#user{password = Md5Pass} when Remember == "true" ->
              %% login successful
              {Y,M,D} = date(),
              Expires= format_expires_date({{Y+1,M,D},time()}),
              Headers=[yaws_api:setcookie("sid", U#user.sid, "/", Expires)],
              Res = {struct, [{status, "ok"}, {"sid", U#user.sid},
                              {group, ?a2l(U#user.role)}]};
          U=#user{password = Md5Pass} ->
              %% login successful
              Headers=[yaws_api:setcookie("sid", U#user.sid, "/")],
              Res = {struct, [{status, "ok"}, {"sid", U#user.sid},
                              {group, ?a2l(U#user.role)}]};
          #user{} ->
              Headers=[],
              Res = {struct, [{status, "error"}, {reason, "invalid password"}]};
          _ ->
              Headers=[],
              Res = {struct, [{status, "error"}, {reason, "unknown user"}]}
      end,
      {{Res,Headers}, S};
  %% http://idrott/idrott/send_reset_password?user=johan
  do_cmd("send_reset_password", L, _Json, _A, S) ->
      User = get_val("user", L, ""),
      case get_user_by_name(User, S) of
          U=#user{} ->
  