- if domain_to.nil?
- # There was no "@" in the destination user.
- msg = "the destination user #{user_to} is not valid"
- raise InvalidUserError.new(msg)
+ # Move the user *src* to *dst* within the Postfixadmin
+ # database. This should "rename" him in _every_ table where he is
+ # referenced. Unfortunately that must be done manually.
+ #
+ # This can fail is *src* does not exist, or if *dst* already exists
+ # before the move. It will also fail if the domain associated with
+ # the user *dst* does not exist.
+ #
+ # @param src [User] the source user to be moved.
+ #
+ # @param dst [User] the destination user being moved to.
+ #
+ def mv_user(src, dst)
+ raise NonexistentUserError.new(src.to_s()) if not user_exists(src)
+
+ if not domain_exists(dst.domain())
+ raise NonexistentDomainError.new(dst.domain.to_s())