Fix endless reload of login page

This commit is contained in:
Eike Kettner
2020-12-06 00:58:15 +01:00
parent 89a66ebe8c
commit f55566388a
2 changed files with 20 additions and 5 deletions

View File

@ -125,7 +125,12 @@ updateWithSub msg model =
else else
Cmd.batch Cmd.batch
[ Ports.removeAccount () [ Ports.removeAccount ()
, Page.goto (Page.loginPage model.page) , case model.page of
LoginPage _ ->
Cmd.none
_ ->
Page.goto (Page.loginPage model.page)
] ]
in in
( { model | flags = newFlags }, command, Sub.none ) ( { model | flags = newFlags }, command, Sub.none )
@ -134,7 +139,12 @@ updateWithSub msg model =
( model ( model
, Cmd.batch , Cmd.batch
[ Ports.removeAccount () [ Ports.removeAccount ()
, Page.goto (Page.loginPage model.page) , case model.page of
LoginPage _ ->
Cmd.none
_ ->
Page.goto (Page.loginPage model.page)
] ]
, Sub.none , Sub.none
) )

View File

@ -2,7 +2,6 @@ module Page.Login.Update exposing (update)
import Api import Api
import Api.Model.AuthResult exposing (AuthResult) import Api.Model.AuthResult exposing (AuthResult)
import Api.Model.UserPass exposing (UserPass)
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Page exposing (Page(..)) import Page exposing (Page(..))
import Page.Login.Data exposing (..) import Page.Login.Data exposing (..)
@ -38,10 +37,16 @@ update referrer flags msg model =
Maybe.withDefault HomePage referrer |> Page.goto Maybe.withDefault HomePage referrer |> Page.goto
in in
if lr.success then if lr.success then
( { model | result = Just lr, password = "" }, Cmd.batch [ setAccount lr, gotoRef ], Just lr ) ( { model | result = Just lr, password = "" }
, Cmd.batch [ setAccount lr, gotoRef ]
, Just lr
)
else else
( { model | result = Just lr, password = "" }, Ports.removeAccount (), Just lr ) ( { model | result = Just lr, password = "" }
, Ports.removeAccount ()
, Just lr
)
AuthResp (Err err) -> AuthResp (Err err) ->
let let