anchor.diff:      end.
   
   
  -% -spec check_user(Username::string()) -> tuple().
  -% check_user(Username) ->
  -%     case erlastic_search:get_doc(?INDEX, "user", Username) of
  -%         {error, {404, _}}     -> true;
  -%         {error, {Code, Body}} -> {Code, Body};
  -%         {ok,JsonStruct}       -> false
  -%     end.
  -
   -spec get_user_by_name(Username::string()) -> tuple().
   get_user_by_name(Username) ->
       % {_, JSON} = erlastic_search:get_doc(?INDEX, "user", Username),
  
positive.code:         Id ->  string:to_lower(Id)
      end.
  
  %% @doc
  %% Function: add_server_side_fields/1
  %% Purpose: Used to add all the fields that should be added server side
  
negative.code:             {description, Description},
              {image_url, URL},
              {access_token, AccToken},
              {refresh_token, RefreshT},
              {admin, Admin}]
      }).
  
  
  -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 ->
  