on master help sign in
Got email working
commitf08aed3da6196818c564a4bc0a8a052da79415f5 authoriko <ilyakooo0@gmail.com> dateSat 30 Jul 2022, 18:53 (4 years ago) parentb90989e
6 files changed+32−8
backend/Bridge.purs+2 backend/Main.purs+4 bridge.yaml+2 frontend/Bridge.elm+6 frontend/Main.elm+15−5 frontend/Pages/Ciphers.elm+3−3
backend/Bridge.purs+2
@@ -31,6 +31,7 @@ data Cmd =
3131 Init
3232 | Login Cmd_Login
3333 | NeedCiphersList
34+ | NeedEmail
3435 | NeedsReset
3536 | RequestCipher String
3637 | SendMasterPassword String
@@ -494,6 +495,7 @@ data Sub =
494495 | LoginSuccessful
495496 | NeedsLogin
496497 | NeedsMasterPassword Sub_NeedsMasterPassword
498+ | RecieveEmail String
497499 | Reset
498500
499501instance encodeJsonSub :: EncodeJson Sub where
backend/Main.purs+4
@@ -202,6 +202,10 @@ main = do
202202 send $ Bridge.LoadCipher $ Bridge.Sub_LoadCipher {cipherType, name, id}
203203 pure unit
204204 pure unit
205+ Bridge.NeedEmail -> run do
206+ sync <- getOrReset storage SyncKey
207+ send $ Bridge.RecieveEmail sync.profile.email
208+ pure unit
205209
206210data SyncKey = SyncKey
207211
bridge.yaml+2
@@ -77,6 +77,7 @@ Sub:
7777 Maybe: String
7878 licenseNumber:
7979 Maybe: String
80+- RecieveEmail: String
8081
8182Cmd:
8283- Init
@@ -88,3 +89,4 @@ Cmd:
8889- SendMasterPassword: String
8990- NeedsReset
9091- RequestCipher: String
92+- NeedEmail
frontend/Bridge.elm+6
@@ -35,6 +35,7 @@ type Cmd =
3535 Init
3636 | Login Cmd_Login
3737 | NeedCiphersList
38+ | NeedEmail
3839 | NeedsReset
3940 | RequestCipher String
4041 | SendMasterPassword String
@@ -45,6 +46,7 @@ jsonDecCmd =
4546 [ ("Init", Json.Decode.lazy (\_ -> Json.Decode.succeed Init))
4647 , ("Login", Json.Decode.lazy (\_ -> Json.Decode.map Login (jsonDecCmd_Login)))
4748 , ("NeedCiphersList", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedCiphersList))
49+ , ("NeedEmail", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedEmail))
4850 , ("NeedsReset", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedsReset))
4951 , ("RequestCipher", Json.Decode.lazy (\_ -> Json.Decode.map RequestCipher (Json.Decode.string)))
5052 , ("SendMasterPassword", Json.Decode.lazy (\_ -> Json.Decode.map SendMasterPassword (Json.Decode.string)))
@@ -58,6 +60,7 @@ jsonEncCmd val =
5860 Init -> ("Init", encodeValue (Json.Encode.list identity []))
5961 Login v1 -> ("Login", encodeValue (jsonEncCmd_Login v1))
6062 NeedCiphersList -> ("NeedCiphersList", encodeValue (Json.Encode.list identity []))
63+ NeedEmail -> ("NeedEmail", encodeValue (Json.Encode.list identity []))
6164 NeedsReset -> ("NeedsReset", encodeValue (Json.Encode.list identity []))
6265 RequestCipher v1 -> ("RequestCipher", encodeValue (Json.Encode.string v1))
6366 SendMasterPassword v1 -> ("SendMasterPassword", encodeValue (Json.Encode.string v1))
@@ -621,6 +624,7 @@ type Sub =
621624 | LoginSuccessful
622625 | NeedsLogin
623626 | NeedsMasterPassword Sub_NeedsMasterPassword
627+ | RecieveEmail String
624628 | Reset
625629
626630jsonDecSub : Json.Decode.Decoder ( Sub )
@@ -632,6 +636,7 @@ jsonDecSub =
632636 , ("LoginSuccessful", Json.Decode.lazy (\_ -> Json.Decode.succeed LoginSuccessful))
633637 , ("NeedsLogin", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedsLogin))
634638 , ("NeedsMasterPassword", Json.Decode.lazy (\_ -> Json.Decode.map NeedsMasterPassword (jsonDecSub_NeedsMasterPassword)))
639+ , ("RecieveEmail", Json.Decode.lazy (\_ -> Json.Decode.map RecieveEmail (Json.Decode.string)))
635640 , ("Reset", Json.Decode.lazy (\_ -> Json.Decode.succeed Reset))
636641 ]
637642 jsonDecObjectSetSub = Set.fromList []
@@ -646,6 +651,7 @@ jsonEncSub val =
646651 LoginSuccessful -> ("LoginSuccessful", encodeValue (Json.Encode.list identity []))
647652 NeedsLogin -> ("NeedsLogin", encodeValue (Json.Encode.list identity []))
648653 NeedsMasterPassword v1 -> ("NeedsMasterPassword", encodeValue (jsonEncSub_NeedsMasterPassword v1))
654+ RecieveEmail v1 -> ("RecieveEmail", encodeValue (Json.Encode.string v1))
649655 Reset -> ("Reset", encodeValue (Json.Encode.list identity []))
650656 in encodeSumTaggedObject "tag" "contents" keyval val
651657
frontend/Main.elm+15−5
@@ -35,6 +35,7 @@ type Msg
3535 | ShowCipherPage Bridge.Sub_LoadCipher
3636 | RequestCipher CipherId
3737 | PopView
38+ | RecieveEmail String
3839
3940
4041type alias CipherId =
@@ -44,6 +45,7 @@ type alias CipherId =
4445type alias Model =
4546 { notifications : List Notification.Config
4647 , pageStack : Navigation.PageStack PageModel
48+ , userEmail : Maybe String
4749 }
4850
4951
@@ -61,13 +63,14 @@ type PageModel
6163
6264
6365showPage :
64− PageModel
66+ String
67+ -> PageModel
6568 ->
6669 { title : String
6770 , body : List (Html Msg)
6871 , topButton : Maybe (Navigation.TopButton Msg)
6972 }
70−showPage page =
73+showPage email page =
7174 case page of
7275 LoginModel model ->
7376 let
@@ -87,7 +90,7 @@ showPage page =
8790 { title = p.title model
8891 , body = p.view model
8992 , topButton =
90− Ciphers.menuConfig model
93+ Ciphers.menuConfig email model
9194 |> Navigation.mapMenuConfig CiphersMsg
9295 |> Navigation.MenuButton
9396 |> Just
@@ -155,6 +158,9 @@ subscriptions _ =
155158
156159 Bridge.LoadCipher cipher ->
157160 ShowCipherPage cipher
161+
162+ Bridge.RecieveEmail email ->
163+ RecieveEmail email
158164 )
159165
160166
@@ -162,6 +168,7 @@ init : ( Model, Cmd Msg )
162168init =
163169 ( { notifications = []
164170 , pageStack = Nonempty.singleton LoadingPage
171+ , userEmail = Nothing
165172 }
166173 , FFI.sendBridge Bridge.Init
167174 )
@@ -171,7 +178,7 @@ view : Model -> Html Msg
171178view model =
172179 div []
173180 (maybeList (List.head model.notifications) (Lazy.lazy2 Notification.notification CloseNotification)
174− ++ [ Lazy.lazy2 Navigation.showNavigationView model.pageStack showPage ]
181+ ++ [ Lazy.lazy2 Navigation.showNavigationView model.pageStack (showPage (Maybe.withDefault "" model.userEmail)) ]
175182 )
176183
177184
@@ -278,7 +285,7 @@ update msg model =
278285 |> Tuple.mapFirst (\pageModel -> appendPageStack <| CiphersModel pageModel)
279286
280287 OpenCiphersScreen ->
281− ( appendPageStack <| LoadingPage, sendBridge Bridge.NeedCiphersList )
288+ ( appendPageStack <| LoadingPage, Cmd.batch [ sendBridge Bridge.NeedCiphersList, sendBridge Bridge.NeedEmail ] )
282289
283290 Reset ->
284291 init
@@ -321,6 +328,9 @@ update msg model =
321328 , Cmd.none
322329 )
323330
331+ RecieveEmail email ->
332+ ( { model | userEmail = Just email }, Cmd.none )
333+
324334
325335loginCallbacks : Login.Callbacks Msg
326336loginCallbacks =
frontend/Pages/Ciphers.elm+3−3
@@ -34,9 +34,9 @@ applyCipherFilter filter list =
3434 list |> List.filter (.cipherType >> (==) t)
3535
3636
37−menuConfig : Model -> Navigation.MenuConfig Msg
38−menuConfig { ciphersListFilter, menuVisible } =
39− { title = "TODO"
37+menuConfig : String -> Model -> Navigation.MenuConfig Msg
38+menuConfig email { ciphersListFilter, menuVisible } =
39+ { title = email
4040 , items =
4141 [ { icon = "units"
4242 , name = "All items"