on master help sign in
Got email working
f08aed3iko
backend/Bridge.purs+2
@@ -31,6 +31,7 @@ data Cmd =
31 Init
31 Init
32 | Login Cmd_Login
32 | Login Cmd_Login
33 | NeedCiphersList
33 | NeedCiphersList
34+ | NeedEmail
34 | NeedsReset
35 | NeedsReset
35 | RequestCipher String
36 | RequestCipher String
36 | SendMasterPassword String
37 | SendMasterPassword String
@@ -494,6 +495,7 @@ data Sub =
494 | LoginSuccessful
495 | LoginSuccessful
495 | NeedsLogin
496 | NeedsLogin
496 | NeedsMasterPassword Sub_NeedsMasterPassword
497 | NeedsMasterPassword Sub_NeedsMasterPassword
498+ | RecieveEmail String
497 | Reset
499 | Reset
498
500
499instance encodeJsonSub :: EncodeJson Sub where
501instance encodeJsonSub :: EncodeJson Sub where
backend/Main.purs+4
@@ -202,6 +202,10 @@ main = do
202 send $ Bridge.LoadCipher $ Bridge.Sub_LoadCipher {cipherType, name, id}
202 send $ Bridge.LoadCipher $ Bridge.Sub_LoadCipher {cipherType, name, id}
203 pure unit
203 pure unit
204 pure unit
204 pure unit
205+ Bridge.NeedEmail -> run do
206+ sync <- getOrReset storage SyncKey
207+ send $ Bridge.RecieveEmail sync.profile.email
208+ pure unit
205
209
206data SyncKey = SyncKey
210data SyncKey = SyncKey
207
211
bridge.yaml+2
@@ -77,6 +77,7 @@ Sub:
77 Maybe: String
77 Maybe: String
78 licenseNumber:
78 licenseNumber:
79 Maybe: String
79 Maybe: String
80+- RecieveEmail: String
80
81
81Cmd:
82Cmd:
82- Init
83- Init
@@ -88,3 +89,4 @@ Cmd:
88- SendMasterPassword: String
89- SendMasterPassword: String
89- NeedsReset
90- NeedsReset
90- RequestCipher: String
91- RequestCipher: String
92+- NeedEmail
frontend/Bridge.elm+6
@@ -35,6 +35,7 @@ type Cmd =
35 Init
35 Init
36 | Login Cmd_Login
36 | Login Cmd_Login
37 | NeedCiphersList
37 | NeedCiphersList
38+ | NeedEmail
38 | NeedsReset
39 | NeedsReset
39 | RequestCipher String
40 | RequestCipher String
40 | SendMasterPassword String
41 | SendMasterPassword String
@@ -45,6 +46,7 @@ jsonDecCmd =
45 [ ("Init", Json.Decode.lazy (\_ -> Json.Decode.succeed Init))
46 [ ("Init", Json.Decode.lazy (\_ -> Json.Decode.succeed Init))
46 , ("Login", Json.Decode.lazy (\_ -> Json.Decode.map Login (jsonDecCmd_Login)))
47 , ("Login", Json.Decode.lazy (\_ -> Json.Decode.map Login (jsonDecCmd_Login)))
47 , ("NeedCiphersList", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedCiphersList))
48 , ("NeedCiphersList", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedCiphersList))
49+ , ("NeedEmail", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedEmail))
48 , ("NeedsReset", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedsReset))
50 , ("NeedsReset", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedsReset))
49 , ("RequestCipher", Json.Decode.lazy (\_ -> Json.Decode.map RequestCipher (Json.Decode.string)))
51 , ("RequestCipher", Json.Decode.lazy (\_ -> Json.Decode.map RequestCipher (Json.Decode.string)))
50 , ("SendMasterPassword", Json.Decode.lazy (\_ -> Json.Decode.map SendMasterPassword (Json.Decode.string)))
52 , ("SendMasterPassword", Json.Decode.lazy (\_ -> Json.Decode.map SendMasterPassword (Json.Decode.string)))
@@ -58,6 +60,7 @@ jsonEncCmd val =
58 Init -> ("Init", encodeValue (Json.Encode.list identity []))
60 Init -> ("Init", encodeValue (Json.Encode.list identity []))
59 Login v1 -> ("Login", encodeValue (jsonEncCmd_Login v1))
61 Login v1 -> ("Login", encodeValue (jsonEncCmd_Login v1))
60 NeedCiphersList -> ("NeedCiphersList", encodeValue (Json.Encode.list identity []))
62 NeedCiphersList -> ("NeedCiphersList", encodeValue (Json.Encode.list identity []))
63+ NeedEmail -> ("NeedEmail", encodeValue (Json.Encode.list identity []))
61 NeedsReset -> ("NeedsReset", encodeValue (Json.Encode.list identity []))
64 NeedsReset -> ("NeedsReset", encodeValue (Json.Encode.list identity []))
62 RequestCipher v1 -> ("RequestCipher", encodeValue (Json.Encode.string v1))
65 RequestCipher v1 -> ("RequestCipher", encodeValue (Json.Encode.string v1))
63 SendMasterPassword v1 -> ("SendMasterPassword", encodeValue (Json.Encode.string v1))
66 SendMasterPassword v1 -> ("SendMasterPassword", encodeValue (Json.Encode.string v1))
@@ -621,6 +624,7 @@ type Sub =
621 | LoginSuccessful
624 | LoginSuccessful
622 | NeedsLogin
625 | NeedsLogin
623 | NeedsMasterPassword Sub_NeedsMasterPassword
626 | NeedsMasterPassword Sub_NeedsMasterPassword
627+ | RecieveEmail String
624 | Reset
628 | Reset
625
629
626jsonDecSub : Json.Decode.Decoder ( Sub )
630jsonDecSub : Json.Decode.Decoder ( Sub )
@@ -632,6 +636,7 @@ jsonDecSub =
632 , ("LoginSuccessful", Json.Decode.lazy (\_ -> Json.Decode.succeed LoginSuccessful))
636 , ("LoginSuccessful", Json.Decode.lazy (\_ -> Json.Decode.succeed LoginSuccessful))
633 , ("NeedsLogin", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedsLogin))
637 , ("NeedsLogin", Json.Decode.lazy (\_ -> Json.Decode.succeed NeedsLogin))
634 , ("NeedsMasterPassword", Json.Decode.lazy (\_ -> Json.Decode.map NeedsMasterPassword (jsonDecSub_NeedsMasterPassword)))
638 , ("NeedsMasterPassword", Json.Decode.lazy (\_ -> Json.Decode.map NeedsMasterPassword (jsonDecSub_NeedsMasterPassword)))
639+ , ("RecieveEmail", Json.Decode.lazy (\_ -> Json.Decode.map RecieveEmail (Json.Decode.string)))
635 , ("Reset", Json.Decode.lazy (\_ -> Json.Decode.succeed Reset))
640 , ("Reset", Json.Decode.lazy (\_ -> Json.Decode.succeed Reset))
636 ]
641 ]
637 jsonDecObjectSetSub = Set.fromList []
642 jsonDecObjectSetSub = Set.fromList []
@@ -646,6 +651,7 @@ jsonEncSub val =
646 LoginSuccessful -> ("LoginSuccessful", encodeValue (Json.Encode.list identity []))
651 LoginSuccessful -> ("LoginSuccessful", encodeValue (Json.Encode.list identity []))
647 NeedsLogin -> ("NeedsLogin", encodeValue (Json.Encode.list identity []))
652 NeedsLogin -> ("NeedsLogin", encodeValue (Json.Encode.list identity []))
648 NeedsMasterPassword v1 -> ("NeedsMasterPassword", encodeValue (jsonEncSub_NeedsMasterPassword v1))
653 NeedsMasterPassword v1 -> ("NeedsMasterPassword", encodeValue (jsonEncSub_NeedsMasterPassword v1))
654+ RecieveEmail v1 -> ("RecieveEmail", encodeValue (Json.Encode.string v1))
649 Reset -> ("Reset", encodeValue (Json.Encode.list identity []))
655 Reset -> ("Reset", encodeValue (Json.Encode.list identity []))
650 in encodeSumTaggedObject "tag" "contents" keyval val
656 in encodeSumTaggedObject "tag" "contents" keyval val
651
657
frontend/Main.elm+15−5
@@ -35,6 +35,7 @@ type Msg
35 | ShowCipherPage Bridge.Sub_LoadCipher
35 | ShowCipherPage Bridge.Sub_LoadCipher
36 | RequestCipher CipherId
36 | RequestCipher CipherId
37 | PopView
37 | PopView
38+ | RecieveEmail String
38
39
39
40
40type alias CipherId =
41type alias CipherId =
@@ -44,6 +45,7 @@ type alias CipherId =
44type alias Model =
45type alias Model =
45 { notifications : List Notification.Config
46 { notifications : List Notification.Config
46 , pageStack : Navigation.PageStack PageModel
47 , pageStack : Navigation.PageStack PageModel
48+ , userEmail : Maybe String
47 }
49 }
48
50
49
51
@@ -61,13 +63,14 @@ type PageModel
61
63
62
64
63showPage :
65showPage :
66+ String
64− PageModel
67+ -> PageModel
65 ->
68 ->
66 { title : String
69 { title : String
67 , body : List (Html Msg)
70 , body : List (Html Msg)
68 , topButton : Maybe (Navigation.TopButton Msg)
71 , topButton : Maybe (Navigation.TopButton Msg)
69 }
72 }
70−showPage page =
73+showPage email page =
71 case page of
74 case page of
72 LoginModel model ->
75 LoginModel model ->
73 let
76 let
@@ -87,7 +90,7 @@ showPage page =
87 { title = p.title model
90 { title = p.title model
88 , body = p.view model
91 , body = p.view model
89 , topButton =
92 , topButton =
90− Ciphers.menuConfig model
93+ Ciphers.menuConfig email model
91 |> Navigation.mapMenuConfig CiphersMsg
94 |> Navigation.mapMenuConfig CiphersMsg
92 |> Navigation.MenuButton
95 |> Navigation.MenuButton
93 |> Just
96 |> Just
@@ -155,6 +158,9 @@ subscriptions _ =
155
158
156 Bridge.LoadCipher cipher ->
159 Bridge.LoadCipher cipher ->
157 ShowCipherPage cipher
160 ShowCipherPage cipher
161+
162+ Bridge.RecieveEmail email ->
163+ RecieveEmail email
158 )
164 )
159
165
160
166
@@ -162,6 +168,7 @@ init : ( Model, Cmd Msg )
162init =
168init =
163 ( { notifications = []
169 ( { notifications = []
164 , pageStack = Nonempty.singleton LoadingPage
170 , pageStack = Nonempty.singleton LoadingPage
171+ , userEmail = Nothing
165 }
172 }
166 , FFI.sendBridge Bridge.Init
173 , FFI.sendBridge Bridge.Init
167 )
174 )
@@ -171,7 +178,7 @@ view : Model -> Html Msg
171view model =
178view model =
172 div []
179 div []
173 (maybeList (List.head model.notifications) (Lazy.lazy2 Notification.notification CloseNotification)
180 (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)) ]
175 )
182 )
176
183
177
184
@@ -278,7 +285,7 @@ update msg model =
278 |> Tuple.mapFirst (\pageModel -> appendPageStack <| CiphersModel pageModel)
285 |> Tuple.mapFirst (\pageModel -> appendPageStack <| CiphersModel pageModel)
279
286
280 OpenCiphersScreen ->
287 OpenCiphersScreen ->
281− ( appendPageStack <| LoadingPage, sendBridge Bridge.NeedCiphersList )
288+ ( appendPageStack <| LoadingPage, Cmd.batch [ sendBridge Bridge.NeedCiphersList, sendBridge Bridge.NeedEmail ] )
282
289
283 Reset ->
290 Reset ->
284 init
291 init
@@ -321,6 +328,9 @@ update msg model =
321 , Cmd.none
328 , Cmd.none
322 )
329 )
323
330
331+ RecieveEmail email ->
332+ ( { model | userEmail = Just email }, Cmd.none )
333+
324
334
325loginCallbacks : Login.Callbacks Msg
335loginCallbacks : Login.Callbacks Msg
326loginCallbacks =
336loginCallbacks =
frontend/Pages/Ciphers.elm+3−3
@@ -34,9 +34,9 @@ applyCipherFilter filter list =
34 list |> List.filter (.cipherType >> (==) t)
34 list |> List.filter (.cipherType >> (==) t)
35
35
36
36
37−menuConfig : Model -> Navigation.MenuConfig Msg
37+menuConfig : String -> Model -> Navigation.MenuConfig Msg
38−menuConfig { ciphersListFilter, menuVisible } =
38+menuConfig email { ciphersListFilter, menuVisible } =
39− { title = "TODO"
39+ { title = email
40 , items =
40 , items =
41 [ { icon = "units"
41 [ { icon = "units"
42 , name = "All items"
42 , name = "All items"