made login redirect go to previous page, except after logout go to index