<commit_before>defmodule Dsps.Session do
    alias Dsps.User

    def login(params, repo) do
        user = repo.get_by(User, username: params["username"])
        case authenticate(user, params["password"]) do
            true -> {:ok, user}
            _ ->    :error
        end
    end

    defp authenticate(user, password) do
        case user do
            nil -> false
            _ -> Comeonin.Bcrypt.checkpw(password, user.password)
        end
    end

    def current_user(conn) do
        id = Plug.Conn.get_session(conn, :current_user)
        if id, do: Dsps.Repo.get(User, id)
    end

    def logged_in?(conn), do: !!current_user(conn)
end<commit_msg>Rewriting session model<commit_after>defmodule Dsps.Session do
    alias Dsps.User

    def login(params, repo) do
        user = repo.get_by(User, username: params["username"])
        case authenticate(user, params["password"]) do
            true -> {:ok, user}
            _ ->    :error
        end
    end

    defp authenticate(user, password) do
        case user do
            nil -> false
            _ -> Comeonin.Bcrypt.checkpw(password, user.password)
        end
    end

    def current_user(conn) do
        
    end

    def logged_in?(conn), do: !!current_user(conn)
end
{'fraction_non_alphanumeric': 0.10333863275039745, 'fraction_numerical': 0.0, 'mean_word_length': 2.0191846522781773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6680495', 'n_tokens_mistral': 399, 'n_tokens_neox': 381, 'n_words': 99}