Last active
February 15, 2017 11:17
-
-
Save VelizarHristov/e5efdb5a9d5212ee6705e82f356bc72b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Server.login emailEntry.Text passwordEntry.Text) |> Async.map (fun res -> | |
match res with | |
| Server.Success -> f() // login | |
| Server.IncorrectPassword -> outputLabel.Text <- "Incorrect password" | |
| Server.EmailNotFound -> outputLabel.Text <- "Email not found" | |
| Server.NotActivated -> outputLabel.Text <- "Account not activated" | |
| _ -> outputLabel.Text <- "Error, please try again" | |
) |> Async.StartImmediate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If ServerWrapper just returned the raw server output | |
(Server.login emailEntry.Text passwordEntry.Text) |> Async.map (fun res -> | |
match res with | |
| "Success" -> f() // login | |
| "IncorrectPassword" -> outputLabel.Text <- "Incorrect password" | |
| "EmailNotFound" -> outputLabel.Text <- "Email not found" | |
| "NotActivated" -> outputLabel.Text <- "Account not activated" | |
| _ -> outputLabel.Text <- "Error, please try again" | |
) |> Async.StartImmediate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type LoginResult = | |
| Success | |
| IncorrectPassword | |
| EmailNotFound | |
| NotActivated | |
| Error | |
let loginFake _ _ = async { return Success } | |
let login email password = | |
sprintf "login?email=%s&password=%s" email password | |
|> fetchUrlAsync | |
|> Async.map (fun res -> | |
match res with | |
| "Success" -> Success | |
| "IncorrectPassword" -> IncorrectPassword | |
| "EmailNotFound" -> EmailNotFound | |
| "NotActivated" -> NotActivated | |
| _ -> Error | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment