From 0b6f965fcb0dc0d69bc79746220079f3d23497a7 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Fri, 4 Dec 2020 22:57:21 +0100 Subject: [PATCH] Fix rememberme for missing local storage --- .../src/main/scala/docspell/backend/auth/Login.scala | 8 +++++--- modules/webapp/src/main/elm/App/Update.elm | 12 ++++++++++-- modules/webapp/src/main/elm/Main.elm | 10 +--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/modules/backend/src/main/scala/docspell/backend/auth/Login.scala b/modules/backend/src/main/scala/docspell/backend/auth/Login.scala index 9540f6e4..050d99d4 100644 --- a/modules/backend/src/main/scala/docspell/backend/auth/Login.scala +++ b/modules/backend/src/main/scala/docspell/backend/auth/Login.scala @@ -124,11 +124,13 @@ object Login { minTime = now - config.rememberMe.valid data <- OptionT(store.transact(QLogin.findByRememberMe(rid, minTime).value)) _ <- OptionT.liftF( - logF.warn(s"Account lookup via remember me: $data") + logF.info(s"Account lookup via remember me: $data") ) res <- OptionT.liftF( - if (checkNoPassword(data)) okResult(data.account) - else Result.invalidAuth.pure[F] + if (checkNoPassword(data)) + logF.info("RememberMe auth successful") *> okResult(data.account) + else + logF.warn("RememberMe auth not successfull") *> Result.invalidAuth.pure[F] ) } yield res).getOrElseF( logF.info("RememberMe not found in database.") *> Result.invalidAuth.pure[F] diff --git a/modules/webapp/src/main/elm/App/Update.elm b/modules/webapp/src/main/elm/App/Update.elm index ceb24014..359adf8c 100644 --- a/modules/webapp/src/main/elm/App/Update.elm +++ b/modules/webapp/src/main/elm/App/Update.elm @@ -7,7 +7,6 @@ import Api import App.Data exposing (..) import Browser exposing (UrlRequest(..)) import Browser.Navigation as Nav -import Comp.LinkTarget import Data.Flags import Page exposing (Page(..)) import Page.CollectiveSettings.Data @@ -112,7 +111,16 @@ updateWithSub msg model = command = 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 Cmd.batch diff --git a/modules/webapp/src/main/elm/Main.elm b/modules/webapp/src/main/elm/Main.elm index 773c6297..ce982add 100644 --- a/modules/webapp/src/main/elm/Main.elm +++ b/modules/webapp/src/main/elm/Main.elm @@ -51,21 +51,13 @@ init flags url key = else ( im, Page.goto page, Sub.none ) - - sessionCheck = - case m.flags.account of - Just _ -> - Api.loginSession flags SessionCheckResp - - Nothing -> - Cmd.none in ( { m | subs = s } , Cmd.batch [ cmd , ic , Api.versionInfo flags VersionResp - , sessionCheck + , Api.loginSession flags SessionCheckResp , Ports.getUiSettings flags ] )