Fix page routing with remember me

This commit is contained in:
Eike Kettner 2020-12-11 01:16:39 +01:00
parent 52dec662c5
commit 7e42426edc
3 changed files with 4 additions and 45 deletions

View File

@ -1,7 +1,6 @@
module App.Data exposing
( Model
, Msg(..)
, checkPage
, defaultPage
, init
)
@ -148,29 +147,6 @@ type Msg
| GetUiSettings UiSettings
isSignedIn : Flags -> Bool
isSignedIn flags =
flags.account
|> Maybe.map .success
|> Maybe.withDefault False
checkPage : Flags -> Page -> Page
checkPage flags page =
if Page.isSecured page && isSignedIn flags then
page
else if Page.isOpen page then
page
else
Page.loginPage page
defaultPage : Flags -> Page
defaultPage flags =
if isSignedIn flags then
HomePage
else
LoginPage Nothing
HomePage

View File

@ -178,18 +178,8 @@ updateWithSub msg model =
page =
Page.fromUrl url
|> Maybe.withDefault (defaultPage model.flags)
check =
checkPage model.flags page
( m, c, s ) =
initPage model page
in
if check == page then
( { m | page = page }, c, s )
else
( model, Page.goto check, Sub.none )
( model, Page.goto page, Sub.none )
ToggleNavMenu ->
( { model

View File

@ -42,22 +42,15 @@ init flags url key =
( im, ic ) =
App.Data.init key url flags Data.UiSettings.defaults
page =
checkPage flags im.page
( m, cmd, s ) =
if im.page == page then
App.Update.initPage im page
else
( im, Page.goto page, Sub.none )
App.Update.initPage im im.page
in
( { m | subs = s }
, Cmd.batch
[ cmd
, ic
, Api.versionInfo flags VersionResp
, if Page.isSecured page then
, if Page.isSecured im.page then
Api.loginSession flags SessionCheckResp
else