First we give a standard Diffie-Hellman key exchange. (For now we won't worry about the specifics of the group in which we are working.)
Of course, this is totally vulnerable to man-in-the-middle attacks. To authenticate the two parties with a password, we could try something like the following,
However, this is vulnerable to an offline dictionary attack, since both X and k are available to an eavesdropping attacker. So we could try authenticating using the secret value Z instead, as in the following.
However, while we have secured the protocol against eavesdropping attackers, active attackers can still obtain enough information to perform an offline dictionary attack. (Hint: Imagine an attacker that pretends to be Alice and sends her own X=gx value.) So this is still not sufficient for totally secure password-authenticated key exchange.