You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.
Currently the JoinBoard.process_request/3 takes a user_id and a board_id as part of it's argument list. I keep flip flopping about this, if I should pass in an id or the User/Board.
My current thinking is that, the controller function should be more explicit, probably through a plug about doing lookups for the board and user. If the request is referencing a non-existent resource, then we should return a HTTP error code, showing an un-proccessable request -- this way the internal functions can have a tighter scope of responsibilities, and not have to constantly check for bad references to non-existent Users.
The text was updated successfully, but these errors were encountered:
Right now JoinBoard.process_request/2 is called after an attempt to call Boards.get_board!(board_id) so I feel confident that if the board_id is not valid a 404 response will be sent.
Similarly we attempt to get user_id via user_id = Plug.Conn.get_session(conn, :user_id) -- the expectation is this will result in a nil value OR valid user_id. Technically it could result in an invalid user_id, I see this happen when I reset my local dev db but the browser cookie still has the old user id but I don't see this happening much once in production.
Having JoinBoard.process_request/3 return {:ok, user, board} or {:error, reason} just keeps the code simple. I suppose in a more bullet proof env I could return :board_not_found or :user_not_found but I'm going to skip that for now.
If we did add this in the future, I suppose the good user experience would be to show a 404 for missing board, or forward the user to a help page explaining they should reset their local cookies and try again.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Currently the
JoinBoard.process_request/3
takes auser_id
and aboard_id
as part of it's argument list. I keep flip flopping about this, if I should pass in an id or theUser
/Board
.My current thinking is that, the controller function should be more explicit, probably through a plug about doing lookups for the board and user. If the request is referencing a non-existent resource, then we should return a HTTP error code, showing an un-proccessable request -- this way the internal functions can have a tighter scope of responsibilities, and not have to constantly check for bad references to non-existent Users.
The text was updated successfully, but these errors were encountered: