diff options
author | William Carroll <wpcarro@gmail.com> | 2020-08-02T10·13+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-08-02T10·13+0100 |
commit | d5bc6f963d4c8cdb8990a9946d9a142a32e13d3c (patch) | |
tree | 2dae4ccfef930e0dcb98ddd3b34489510764fdfb /client | |
parent | 57b6472e2fbd963cc18237d596eb61bb767a1206 (diff) |
Protect views from a State with an empty Session
This should simplify UserHome among other views.
Diffstat (limited to 'client')
-rw-r--r-- | client/src/Common.elm | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/client/src/Common.elm b/client/src/Common.elm index a3106114d43a..63ba97b794ac 100644 --- a/client/src/Common.elm +++ b/client/src/Common.elm @@ -25,3 +25,13 @@ allErrors model = } ) ) + + +withSession : State.Model -> (State.Session -> Html State.Msg) -> Html State.Msg +withSession model renderWithSession = + case model.session of + Nothing -> + div [] [ UI.paragraph "You need a valid session to view this page. Please attempt to log in." ] + + Just session -> + renderWithSession session |