Fix bug in register and logout