Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 822 Bytes

README.md

File metadata and controls

33 lines (27 loc) · 822 Bytes

Is this password known?

This elm package checks a given password against the API of haveibeenpwned.com.

Usage

requestPassword: String -> Cmd Msg
requestPassword pass =
    pass
        |> hashAndCut
        |> Debug.log "This will be sent to HaveIBeenPawned.com"
        |> requestPossibleMatches
        |> Http.send PasswordResponse
update msg model =
    case msg of
        SetPassword pass ->
            ( { model | password = pass }, Cmd.none )

        CheckPassword ->
            ( model, requestPassword model.password )

        PasswordResponse (Ok resp) ->
                    ( { model
                        | isPasswordKnown =
                            Just (isPasswordKnown model.password resp)
                    }
                    , Cmd.none
                    )