<commit_before>defmodule Api.Auth.Guardian do
  use Guardian, otp_app: :api
  alias Api.Auth.Helpers

  def subject_for_token(user_json, _claims) do
    user = user_by(user_json, Api.Core.Config.get(Api.Auth, :users))
    readable_projects = Helpers.get_readable_projects(user.name)
    rights = Poison.encode!(%{
      name: user.name,
      readable_projects: readable_projects
    })
    {:ok, rights}
  end

  def resource_from_claims(claims) do
    rights = Api.Core.Utils.atomize(Poison.decode!(claims["sub"]))
    {:ok, rights}
  end

  def user_by(%{"name" => name, "pass" => pass}, users) do<commit_msg>Annotate impls; make function private<commit_after>defmodule Api.Auth.Guardian do
  use Guardian, otp_app: :api
  alias Api.Auth.Helpers

  @impl true
  def subject_for_token(user_json, _claims) do
    user = user_by(user_json, Api.Core.Config.get(Api.Auth, :users))
    readable_projects = Helpers.get_readable_projects(user.name)
    rights = Poison.encode!(%{
      name: user.name,
      readable_projects: readable_projects
    })
    {:ok, rights}
  end
    
  @impl true
  def resource_from_claims(claims) do
    rights = Api.Core.Utils.atomize(Poison.decode!(claims["sub"]))
    {:ok, rights}
  end
    
  defp user_by(%{"name" => name, "pass" => <PASSWORD>}, users) do
{'fraction_non_alphanumeric': 0.1295577967416602, 'fraction_numerical': 0.0, 'mean_word_length': 3.8679245283018866, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7624996', 'n_tokens_mistral': 469, 'n_tokens_neox': 456, 'n_words': 93}