fix a bug at login and create function redirect