onasty/web/src/Pages/Oauth/Callback.elm(view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
module Pages.Oauth.Callback exposing (Model, Msg, page)
import Components.Box
import Components.Utils
import Dict exposing (Dict)
import Effect exposing (Effect)
import Layouts
import Page exposing (Page)
import Route exposing (Route)
import Shared
import View exposing (View)
type alias Msg =
{}
page : Shared.Model -> Route () -> Page Model Msg
page _ route =
Page.new
{ init = init route.query
, update = \_ m -> ( m, Effect.none )
, subscriptions = \_ -> Sub.none
, view = view
}
|> Page.withLayout (\_ -> Layouts.Header {})
type alias Model =
{ error : String }
init : Dict String String -> () -> ( Model, Effect Msg )
init query () =
case
( Dict.get "access_token" query
, Dict.get "refresh_token" query
, Dict.get "error" query
)
of
( Just at, Just rt, _ ) ->
( { error = "" }, Effect.signin { accessToken = at, refreshToken = rt } )
( _, _, Just error ) ->
( { error = error }, Effect.none )
_ ->
( { error = "Invalid server response" }, Effect.none )
view : Model -> View msg
view model =
{ title = "Oauth"
, body =
[ Components.Utils.commonContainer
[ Components.Box.error model.error ]
]
}
|