on master help sign in
Got log out button working
commit37b471f2e4577df28114fa19aed5a369fd5514e1 authoriko <ilyakooo0@gmail.com> dateSat 30 Jul 2022, 19:08 (4 years ago) parentf08aed3
5 files changed+48−38
frontend/Main.elm+1−1 frontend/Pages/Ciphers.elm+7−1 frontend/Pages/Login.elm+23−25 frontend/Pages/MasterPassword.elm+7−9 frontend/Pages/Navigation.elm+10−2
frontend/Main.elm+1−1
@@ -339,7 +339,7 @@ loginCallbacks =
339339
340340ciphersCallbacks : Ciphers.Callbacks Msg
341341ciphersCallbacks =
342− { selected = RequestCipher }
342+ { selected = RequestCipher, logOut = NeedsReset }
343343
344344
345345cipherCallbacks : Cipher.Callbacks
frontend/Pages/Ciphers.elm+7−1
@@ -66,6 +66,7 @@ menuConfig email { ciphersListFilter, menuVisible } =
6666 ]
6767 , toggle = ToggleMenu
6868 , visible = menuVisible
69+ , logOut = LogOut
6970 }
7071
7172
@@ -74,10 +75,12 @@ type Msg
7475 | UpdateSearch String
7576 | ToggleMenu
7677 | UpdateFilter CiphersFilter
78+ | LogOut
7779
7880
7981type alias Callbacks msg =
8082 { selected : String -> msg
83+ , logOut : msg
8184 }
8285
8386
@@ -121,7 +124,7 @@ init ciphers =
121124
122125
123126update : Callbacks emsg -> (Msg -> emsg) -> Msg -> Model -> ( Result String Model, Cmd emsg )
124−update {} liftMsg msg model =
127+update { logOut } liftMsg msg model =
125128 case msg of
126129 Noop ->
127130 ( Ok model, Cmd.none )
@@ -135,6 +138,9 @@ update {} liftMsg msg model =
135138 UpdateFilter filter ->
136139 ( Ok { model | ciphersListFilter = filter, menuVisible = False }, Cmd.none )
137140
141+ LogOut ->
142+ ( Ok model, pureCmd logOut )
143+
138144
139145subscriptions : Model -> Sub Msg
140146subscriptions model =
frontend/Pages/Login.elm+23−25
@@ -69,31 +69,29 @@ subscriptions model =
6969
7070view : Model -> List (Html Msg)
7171view model =
72− [ form []
73− [ label [] [ text "Server" ]
74− , input
75− [ Attr.type_ "url"
76− , Attr.value model.server
77− , Ev.onInput UpdateServer
78− , Attr.attribute "autocomplete" "url"
79− ]
80− []
81− , label [] [ text "Email" ]
82− , input
83− [ Attr.type_ "email"
84− , Attr.value model.email
85− , Ev.onInput UpdateEmail
86− , Attr.attribute "autocomplete" "email"
87− ]
88− []
89− , label [] [ text "Password" ]
90− , input
91− [ Attr.type_ "password"
92− , Attr.value model.password
93− , Ev.onInput UpdatePassword
94− , Attr.attribute "autocomplete" "current-password"
95− ]
96− []
72+ [ label [] [ text "Server" ]
73+ , input
74+ [ Attr.type_ "url"
75+ , Attr.value model.server
76+ , Ev.onInput UpdateServer
77+ , Attr.attribute "autocomplete" "url"
9778 ]
79+ []
80+ , label [] [ text "Email" ]
81+ , input
82+ [ Attr.type_ "email"
83+ , Attr.value model.email
84+ , Ev.onInput UpdateEmail
85+ , Attr.attribute "autocomplete" "email"
86+ ]
87+ []
88+ , label [] [ text "Password" ]
89+ , input
90+ [ Attr.type_ "password"
91+ , Attr.value model.password
92+ , Ev.onInput UpdatePassword
93+ , Attr.attribute "autocomplete" "current-password"
94+ ]
95+ []
9896 , alignRight [ button [ Ev.onClick Submit ] [ text "Log in" ] ]
9997 ]
frontend/Pages/MasterPassword.elm+7−9
@@ -77,15 +77,13 @@ view model =
7777 ]
7878 ]
7979 ]
80− , form []
81− [ label [] [ text "Password" ]
82− , input
83− [ Attr.type_ "password"
84− , Attr.value model.password
85− , Ev.onInput UpdatePassword
86− , Attr.attribute "autocomplete" "current-password"
87− ]
88− []
80+ , label [] [ text "Password" ]
81+ , input
82+ [ Attr.type_ "password"
83+ , Attr.value model.password
84+ , Ev.onInput UpdatePassword
85+ , Attr.attribute "autocomplete" "current-password"
8986 ]
87+ []
9088 , alignRight [ button [ Ev.onClick Submit ] [ text "Log in" ] ]
9189 ]
frontend/Pages/Navigation.elm+10−2
@@ -67,11 +67,12 @@ type alias MenuConfig msg =
6767 , items : List { icon : String, name : String, trigger : msg, current : Bool }
6868 , toggle : msg
6969 , visible : Bool
70+ , logOut : msg
7071 }
7172
7273
7374mapMenuConfig : (a -> b) -> MenuConfig a -> MenuConfig b
74−mapMenuConfig f { title, items, toggle, visible } =
75+mapMenuConfig f { title, items, toggle, visible, logOut } =
7576 { items =
7677 List.map
7778 (\{ icon, name, trigger, current } ->
@@ -81,16 +82,23 @@ mapMenuConfig f { title, items, toggle, visible } =
8182 , title = title
8283 , toggle = f toggle
8384 , visible = visible
85+ , logOut = f logOut
8486 }
8587
8688
8789menu : MenuConfig msg -> Html msg
88−menu { title, items, toggle, visible } =
90+menu { title, items, toggle, visible, logOut } =
8991 div [ Attr.class "p-side-navigation--icons", Attr.classList [ ( "is-drawer-expanded", visible ) ] ]
9092 [ div [ Attr.class "p-side-navigation__overlay" ] []
9193 , nav [ Attr.class "p-side-navigation__drawer" ]
9294 [ div [ Attr.class "p-side-navigation__drawer-header" ]
9395 [ a [ Attr.class "p-side-navigation__toggle--in-drawer", Ev.onClick toggle ] [ text title ]
96+ , button
97+ [ Attr.class "p-button--negative is-inline u-float-right"
98+ , Attr.style "margin-right" "1rem"
99+ , Ev.onClick logOut
100+ ]
101+ [ text "Log out" ]
94102 ]
95103 , ul [ Attr.class "p-side-navigation__list" ]
96104 (items