I'm not sure if you might call it a theory of religion, but as with many ideas in psychology, William James has already been close to modern concepts. Concerning religion, he left us with his wonderful book "The varieties of religious experience", which would be my starting point.
Yes, I know. I am publishing a book this fall that argues James was right. But I thought he wrote before Freud's theories of religion were published, maybe 1900-1910 In writing my book, I am thinking of saying Freud was the last one to propose a comprehensive psychological theory. I think it dates back to 1910-1930 era, or 85 years ago. (There are other theories from the 19th century and of course Durkheim. It has been a long time no matter how you slice it)