3 ms·
> How does LiveView know an action is failable? Sorry I should have been more clear. You should wrap failable actions in a task if you're calling it from a li
by throwawaymaths 3y ago
> How does LiveView know an action is failable?
Sorry I should have been more clear. You should wrap failable actions in a task if you're calling it from a liveview.
> an auth failure should result in a redirect, not a flash
That should happen before the socket plug and perform the redirect before even the websocket upgrade.
- troupo 3y ago> You should wrap failable actions in a task if you're calling it from a liveview. For complex, one-off and schduled tasks? Sure. But when my stuff is literally "get one record from the db and display it" why should it be in the task? Just because you're a "let it crash" purist? I don't think even Erlang advocated this. > That should happen before the socket plug and perform the redirect before even the websocket upgrade. Again, that depends. - An unauthed person accessing a link behind login? Yes. Redirect before anything happens - An unauthed person accessing an expired link (e.g. invitatoon, or private preview)? Oh, I have to acces the DB to check that the link is valid/invalid, and show the page saying that the link has expired - A person with some authorisation accesiing some resource that is only partially available to them? Oh, I still have to show some stuff, and hide some other stuff. The world is significantly more complex than "just run it in a task, throw an error, and let Phoenix show a 404 page automatically"
- throwawaymaths 3y agoHonestly it seems to me you've never tried to do it the "Erlang/Phoenix way" because none of these things are a heavy lift at all. You're making things out to be a burden when they're not.