Add RemovePasswordOnLogin feature

pull/25/head
Bram 2024-05-30 13:53:56 +02:00
parent b465ad1f47
commit 994c99af15
3 changed files with 16515 additions and 5 deletions

16499
index.html Normal file

File diff suppressed because one or more lines are too long

View File

@ -232,6 +232,7 @@ loginWithUsernameAndPasswordV2 { deviceId, initialDeviceDisplayName, username, p
, refresh = Nothing , refresh = Nothing
, value = out.accessToken , value = out.accessToken
} }
, E.RemovePasswordIfNecessary
, out.user , out.user
|> Maybe.map (V.SetUser >> E.ContentUpdate) |> Maybe.map (V.SetUser >> E.ContentUpdate)
|> E.Optional |> E.Optional
@ -283,6 +284,7 @@ loginWithUsernameAndPasswordV3 { deviceId, initialDeviceDisplayName, username, p
, refresh = Nothing , refresh = Nothing
, value = out.accessToken , value = out.accessToken
} }
, E.RemovePasswordIfNecessary
, out.user , out.user
|> Maybe.map (V.SetUser >> E.ContentUpdate) |> Maybe.map (V.SetUser >> E.ContentUpdate)
|> E.Optional |> E.Optional
@ -334,6 +336,7 @@ loginWithUsernameAndPasswordV4 { deviceId, initialDeviceDisplayName, username, p
, refresh = Nothing , refresh = Nothing
, value = out.accessToken , value = out.accessToken
} }
, E.RemovePasswordIfNecessary
, out.user , out.user
|> Maybe.map (V.SetUser >> E.ContentUpdate) |> Maybe.map (V.SetUser >> E.ContentUpdate)
|> E.Optional |> E.Optional
@ -389,6 +392,7 @@ loginWithUsernameAndPasswordV5 { deviceId, initialDeviceDisplayName, username, p
, refresh = Nothing , refresh = Nothing
, value = out.accessToken , value = out.accessToken
} }
, E.RemovePasswordIfNecessary
, out.user , out.user
|> Maybe.map (V.SetUser >> E.ContentUpdate) |> Maybe.map (V.SetUser >> E.ContentUpdate)
|> E.Optional |> E.Optional
@ -445,6 +449,7 @@ loginWithUsernameAndPasswordV6 { deviceId, enableRefreshToken, initialDeviceDisp
, refresh = out.refreshToken , refresh = out.refreshToken
, value = out.accessToken , value = out.accessToken
} }
, E.RemovePasswordIfNecessary
, out.user , out.user
|> Maybe.map (V.SetUser >> E.ContentUpdate) |> Maybe.map (V.SetUser >> E.ContentUpdate)
|> E.Optional |> E.Optional
@ -501,6 +506,7 @@ loginWithUsernameAndPasswordV7 { deviceId, enableRefreshToken, initialDeviceDisp
, refresh = out.refreshToken , refresh = out.refreshToken
, value = out.accessToken , value = out.accessToken
} }
, E.RemovePasswordIfNecessary
, E.ContentUpdate (V.SetUser out.user) , E.ContentUpdate (V.SetUser out.user)
, out.wellKnown , out.wellKnown
|> Maybe.map (.homeserver >> .baseUrl) |> Maybe.map (.homeserver >> .baseUrl)

View File

@ -57,6 +57,9 @@ type alias VaultUpdate =
Types.VaultUpdate Types.VaultUpdate
{-| Adds a custom access token to the Vault. This can be done if no password is
provided or known.
-}
addAccessToken : String -> Vault -> Vault addAccessToken : String -> Vault -> Vault
addAccessToken token (Vault vault) = addAccessToken token (Vault vault) =
Envelope.mapContext (\c -> { c | suggestedAccessToken = Just token }) vault Envelope.mapContext (\c -> { c | suggestedAccessToken = Just token }) vault
@ -74,16 +77,18 @@ addAccessToken token (Vault vault) =
-} -}
fromUserId : String -> Maybe Vault fromUserId : String -> Maybe Vault
fromUserId = fromUserId uid =
User.fromString uid
>> Maybe.map |> User.fromString
|> Maybe.map
(\u -> (\u ->
Envelope.init Envelope.init
{ serverName = "https://" ++ User.domain u { serverName = "https://" ++ User.domain u
, content = Internal.init u , content = Internal.init (Just u)
} }
|> Envelope.mapContext (\c -> { c | username = Just uid })
) )
>> Maybe.map Vault |> Maybe.map Vault
{-| Send a message event to a room. {-| Send a message event to a room.