Programming Phoenix LiveView: duplicate code block; code referenced in text is not present in code block (page 179)

The following code block in the Access Session Data in The Live View section is duplicated:

def​ mount(_params, session, socket) ​do​
​ 	
​ 	  {
​ 	    ​:ok​,
​ 	    assign(
​ 	      socket,
​ 	      ​score:​ 0,
​ 	      ​message:​ ​"​​Guess a number."​,
​ 	      ​session_id:​ session[​"​​live_socket_id"​]
​ 	    )
​ 	  }
​ 	​end​

The text also seems to suggest that the block should include an assignment to current_user leveraging the Accounts.get_user_by_session_token/1 function, but that assignment is not present.

Therefore, the render/1 function that follows causes an error because @current_user.email cannot be accessed.

Hi there! Thanks for pointing this out. The code will be corrected in the next release. In the meantime, you can update your mount function as described here to get it working Programming Phoenix LiveView: Session Data B6.0 (p. 56)