on master help sign in
And yet more refactoring
commitdf3a90b6d9da2192b33629b7c9f706a0fea04c63 authoriko <ilyakooo0@gmail.com> dateWed 3 Aug 2022, 13:00 (4 years ago) parent71c0b5a
2 files changed+18−18
backend/Main.purs+18−17 frontend/FFI.elm−1
backend/Main.purs+18−17
@@ -91,26 +91,26 @@ main = do
9191 sync <- liftPromise $ api.getSync unit
9292 hash <- hashPassword (Password password)
9393 log $ show sync
94− liftEffect $ Ref.write (Just masterKey) masterKeyRef
95− liftEffect $ Storage.store storage UrlsKey server
96− liftEffect $ Storage.store storage MasterPasswordHashKey hash
97− liftEffect $ Storage.store storage PreloginResponseKey prelogin
98− liftEffect $ Storage.store storage SyncKey sync
99− liftEffect $ Storage.store storage TokenKey token
100− liftEffect $ Elm.send app Bridge.LoginSuccessful
94+ liftEffect do
95+ Ref.write (Just masterKey) masterKeyRef
96+ Storage.store storage UrlsKey server
97+ Storage.store storage MasterPasswordHashKey hash
98+ Storage.store storage PreloginResponseKey prelogin
99+ Storage.store storage SyncKey sync
100+ Storage.store storage TokenKey token
101+ Elm.send app Bridge.LoginSuccessful
101102 Bridge.NeedCiphersList ->
102103 run do
103104 sync <- getOrReset SyncKey
104105 ciphers <- traverse processCipher sync.ciphers
105106 let
106107 sortedCiphers = Array.sortWith (_.date >>> Down) ciphers
107− liftEffect $ Elm.send app $ Bridge.LoadCiphers $ Bridge.Sub_LoadCiphers_List $ map _.cipher sortedCiphers
108− liftEffect $ Storage.store storage SyncKey sync
109− pure unit
108+ liftEffect do
109+ Elm.send app $ Bridge.LoadCiphers $ Bridge.Sub_LoadCiphers_List $ map _.cipher sortedCiphers
110+ Storage.store storage SyncKey sync
110111 Bridge.NeedsReset -> do
111112 WebStorage.clear storage
112113 Elm.send app Bridge.Reset
113− pure unit
114114 Bridge.SendMasterPassword masterPassword ->
115115 runElmAff app
116116 $ do
@@ -122,17 +122,18 @@ main = do
122122 sync <- getOrReset SyncKey
123123 prelogin <- getOrReset PreloginResponseKey
124124 masterKey <- Logic.makePreloginKey prelogin (Email sync.profile.email) (Password masterPassword)
125− liftEffect $ Ref.write (Just masterKey) masterKeyRef
126− liftEffect $ Elm.send app Bridge.LoginSuccessful
125+ liftEffect do
126+ Ref.write (Just masterKey) masterKeyRef
127+ Elm.send app Bridge.LoginSuccessful
127128 else do
128129 liftEffect $ Elm.send app $ Bridge.Error "The password is wrong. Please try again."
129130 requestMasterPassword
130− pure unit
131131 Bridge.Init -> do
132132 liftEffect $ Storage.get storage TokenKey
133− >>= \x -> case x of
134− Just _ -> do liftEffect $ Elm.send app Bridge.LoginSuccessful
135− Nothing -> Elm.send app Bridge.NeedsLogin
133+ >>= \x ->
134+ Elm.send app case x of
135+ Just _ -> Bridge.LoginSuccessful
136+ Nothing -> Bridge.NeedsLogin
136137 Bridge.RequestCipher id ->
137138 run do
138139 sync <- getOrReset SyncKey
frontend/FFI.elm−1
@@ -2,7 +2,6 @@ port module FFI exposing (getBridge, sendBridge)
22
33import Bridge
44import Json.Decode as D
5−import Json.Encode as E
65
76
87port bridgeSub : (D.Value -> msg) -> Sub msg