I imagine doing
and then in the same method trying to do
will cause you all sorts of problems.
The reason for this is Identity.logout() does this:
So you are now trying to login on an invalidated Session maybe?
I think the more correct process here is that when a user clicks the logout button you call Identity.logout() and then redirect back to the login page. This should then cause a new Session to start that you can log in on withtout problems.
This area is not something I know a whole lot about, but that would be where I'd start looking. :)