Fix rememberme for missing local storage

This commit is contained in:
Eike Kettner 2020-12-04 22:57:21 +01:00
parent 5eaa8e9ac6
commit 0b6f965fcb
3 changed files with 16 additions and 14 deletions

View File

@ -124,11 +124,13 @@ object Login {
minTime = now - config.rememberMe.valid minTime = now - config.rememberMe.valid
data <- OptionT(store.transact(QLogin.findByRememberMe(rid, minTime).value)) data <- OptionT(store.transact(QLogin.findByRememberMe(rid, minTime).value))
_ <- OptionT.liftF( _ <- OptionT.liftF(
logF.warn(s"Account lookup via remember me: $data") logF.info(s"Account lookup via remember me: $data")
) )
res <- OptionT.liftF( res <- OptionT.liftF(
if (checkNoPassword(data)) okResult(data.account) if (checkNoPassword(data))
else Result.invalidAuth.pure[F] logF.info("RememberMe auth successful") *> okResult(data.account)
else
logF.warn("RememberMe auth not successfull") *> Result.invalidAuth.pure[F]
) )
} yield res).getOrElseF( } yield res).getOrElseF(
logF.info("RememberMe not found in database.") *> Result.invalidAuth.pure[F] logF.info("RememberMe not found in database.") *> Result.invalidAuth.pure[F]

View File

@ -7,7 +7,6 @@ import Api
import App.Data exposing (..) import App.Data exposing (..)
import Browser exposing (UrlRequest(..)) import Browser exposing (UrlRequest(..))
import Browser.Navigation as Nav import Browser.Navigation as Nav
import Comp.LinkTarget
import Data.Flags import Data.Flags
import Page exposing (Page(..)) import Page exposing (Page(..))
import Page.CollectiveSettings.Data import Page.CollectiveSettings.Data
@ -112,7 +111,16 @@ updateWithSub msg model =
command = command =
if lr.success then if lr.success then
Api.refreshSession newFlags SessionCheckResp Cmd.batch
[ Api.refreshSession newFlags SessionCheckResp
, Ports.setAccount lr
, case model.flags.account of
Just _ ->
Cmd.none
Nothing ->
Page.goto model.page
]
else else
Cmd.batch Cmd.batch

View File

@ -51,21 +51,13 @@ init flags url key =
else else
( im, Page.goto page, Sub.none ) ( im, Page.goto page, Sub.none )
sessionCheck =
case m.flags.account of
Just _ ->
Api.loginSession flags SessionCheckResp
Nothing ->
Cmd.none
in in
( { m | subs = s } ( { m | subs = s }
, Cmd.batch , Cmd.batch
[ cmd [ cmd
, ic , ic
, Api.versionInfo flags VersionResp , Api.versionInfo flags VersionResp
, sessionCheck , Api.loginSession flags SessionCheckResp
, Ports.getUiSettings flags , Ports.getUiSettings flags
] ]
) )