improve error message and database consistency during login
improve error message and database consistency during login

sagemathinc/smc,DrXyzzy/smc,sagemathinc/smc,DrXyzzy/smc,DrXyzzy/smc,tscholl2/smc,sagemathinc/smc,tscholl2/smc,tscholl2/smc,tscholl2/smc,sagemathinc/smc,tscholl2/smc,DrXyzzy/smc