A line in a proof regarding nth power residues I would appreciate help understanding this highlighted line in a proof in Ireland & Rosen (p. 45). I don't know much group theory although I know the residue classes $\pmod m$ form a multiplicative group whose order is $\phi(m)$. 
Prop 4.2.1: If $m\in \mathbb{Z}^{+}$ and $(a,m)=1$ then $a$ is an $n$th power residue iff $a^{\phi(m)/d} \equiv 1\pmod m$ where $d= (n,\phi(m))$:
In the proof it says: If $g$ is a primitive root $\pmod m$ and $a=g^b$ and $x=g^y$ then $x^n\equiv a\pmod m$ is equivalent to $g^{ny} \equiv g^b\pmod m$ (so far so good) which is equivalent to:


If $g^{ny}\equiv g^b \pmod m$ then $ny\equiv b\pmod {\phi(m)}$


Thanks
EDIT Due to my carelessness, I left out a crucial part of the statement of the Proposition. It should be "if $m$ possesses primitive roots, etc" I left my misstatement above as it stands since it resulted in the illuminating answer from @Daniel Fischer below.
 A: As written, the condition is only correct when there exists a primitive root modulo $m$, i.e. when the group of units of $\mathbb{Z}/(m)$ is cyclic. In that case, the highlighted line holds because we have $g^{ny} \equiv g^b \pmod{m} \iff g^{ny-b} \equiv 1 \pmod{m}$, and $g^k \equiv 1 \pmod{m}$ if and only if $k$ is a multiple of the order of $g$. By definition, a primitive root modulo $m$ has order $\phi(m)$, so $g^k \equiv 1 \pmod{m} \iff \phi(m) \mid k$, and $\phi(m) \mid k$ is the definition of $k \equiv 0 \pmod{\phi(m)}$. So
\begin{align}
g^{ny} \equiv g^b \pmod{m} &\iff g^{ny-b} \equiv 1 \pmod{m}\\
&\iff ny -b \equiv 0 \pmod{\phi(m)}\\
&\iff ny \equiv b \pmod{\phi(m)}.
\end{align}
As an example that the condition as written does not hold for all $m$, take $m = 15$ and $n = 4$. Then $\phi(m) = 8$, and $d = (n,\phi(m)) = 4$, so the condition is $a^{8/4} = a^2 \equiv 1 \pmod{15}$, but this congruence is satisfied by $1,4,11,14 \pmod{15}$, while $b^4 \equiv 1 \pmod{15}$ for all $b$ coprime to $15$, so the only biquadratic residue modulo $15$ is $1$.
For general $m$, we must replace Euler's totient function $\phi$ with the Carmichael function $\lambda$. For $a$ coprime to $m$, and $n \in \mathbb{N}\setminus \{0\}$, $a$ is an $n^{\text{th}}$-power residue if and only if $a^{\lambda(m)/d} \equiv 1 \pmod{m}$, where $d = \gcd(n,\lambda(m))$. The proof is similar to the proof when the group of units of $\mathbb{Z}/(m)$ is cyclic, one writes the unit group as a product of cyclic groups and argues in each factor in the given way.
