mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 18:39:33 +00:00
Fix page routing with remember me
This commit is contained in:
parent
52dec662c5
commit
7e42426edc
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user