copy part function from registration controller to login controller