rewrite login with mongodb