Skip to content

Instantly share code, notes, and snippets.

@VelizarHristov
Last active February 15, 2017 11:17
Show Gist options
  • Save VelizarHristov/e5efdb5a9d5212ee6705e82f356bc72b to your computer and use it in GitHub Desktop.
Save VelizarHristov/e5efdb5a9d5212ee6705e82f356bc72b to your computer and use it in GitHub Desktop.
(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
// 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
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