[Code Review]Check if user session is set in every action of the controller

Please review my daily_update_controller code. https://github.com/sushant12/stipe/commit/4f44ab9fdb56da8f594036920768b141171abfa2?diff=unified#diff-cf8a1d4165427de0c59fd55c76f94a76

What I want to ask is, when a user visits the controller, then valid_user? plug function is triggered. That function is defined in the same controller, so is it a good idea to do that or should i have moved that code to action/2?

Seems fine to me personally. :slight_smile:

Another option would be to assign current_user into the connection during your valid_user? call. assign(conn, :current_user, user)

If you need access to the current_user you get it by conn.assigns.current_user

Keeps from having to create a custom action in your controllers which might not be immediately obvious. That pattern can also start to get cumbersome if you need to pass other current values. E.g., current_account when accounts have multiple users.