I built a theme, after logging in, I get redirected here:.
General developer forum
Why does my login redirect to draftfile.php rather than Home?
Redirects happen because $CFG->wantsurl is set to something on login. Usually that happens when you set a bookmark to something other than the login page for your site (in your case, a draft file). If your session has expired, Moodle forwards you to the login page for authentication and then back to the original page you requested. You will want to check your theme to see if it sets $CFG->wantsurl, but I would guess your problem is unrelated to it.