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

View File

@ -2,7 +2,6 @@ module Page.Login.Update exposing (update)
import Api
import Api.Model.AuthResult exposing (AuthResult)
import Api.Model.UserPass exposing (UserPass)
import Data.Flags exposing (Flags)
import Page exposing (Page(..))
import Page.Login.Data exposing (..)
@ -38,10 +37,16 @@ update referrer flags msg model =
Maybe.withDefault HomePage referrer |> Page.goto
in
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
( { model | result = Just lr, password = "" }, Ports.removeAccount (), Just lr )
( { model | result = Just lr, password = "" }
, Ports.removeAccount ()
, Just lr
)
AuthResp (Err err) ->
let