anchor.diff:      Req = string:sub_string(lists:nth(length(URIList),URIList),1,7),
       case Req of
           "_auth"   -> process_auth_request(ReqData, State);
  -        % "_signin" -> process_signin(ReqData, State);
           "_search" -> process_search(ReqData, State, post);
           _ -> create_user(ReqData, State)
       end.
  +
       % case api_help:is_auth(ReqData) of
       %     true  -> process_auth_request(ReqData, State);
       %     false ->
  
positive.code:     }).
  
  
  -spec user_is_new(UserData::string()) -> tuple().
  user_is_new(UserData) ->
      % Username = binary_to_list(proplists:get_value(<<"id">>, UserData)),
      % check_and_sanitize(Username).
  
      Username = binary_to_list(proplists:get_value(<<"id">>, UserData)),
      case get_user_by_name(Username) of
          {error, Msg} -> true;
          {ok, JSON}   -> false
      end.
  
      % Username = binary_to_list(lib_json:get_field(UserJSON, "username")),
      % case check_and_sanitize(Username) of
      %     invalidcharacters ->
      %         "Username characters are not valid";
      %     false ->
      %         "User already exists";
      %     {Code, Body} ->
      %         Body;
      %     true ->
      %         {_, Res} = store_user(Username, UserJSON),
      %         Res
      % end.
  
  
  -spec store_user(UserData::string(), AccToken::string(), RefToken::string()) -> tuple().
  
negative.code:                 {error, {Code, Body}} -> {Code, Body};
                  {ok,JsonStruct}       -> false
              end;
          _ ->  invalidcharacters
      end.
  
  
  -spec get_user_by_name(Username::string()) -> tuple().
  get_user_by_name(Username) ->
      case erlastic_search:get_doc(?INDEX, "user", string:to_lower(Username), [{<<"fields">>, <<"password,_source">>}]) of
          {error, {Code1, Body1}} ->
              ErrorString = api_help:generate_error(Body1, Code1),
              {error, ErrorString};
  
          {ok, JsonStruct} ->
              FinalJson = api_help:get_and_add_password(JsonStruct),
              {ok, FinalJson}
      end.
  
  
  