VaporRecaptcha

1.0.0

A Vapor 3 library for validating Google reCAPTCHA submissions
gotranseo/vapor-recaptcha

What's New

Vapor reCAPTCHA 1.0.0

2018-05-08T00:34:29Z

Please see the README for instructions

Vapor reCAPTCHA

Motivation

This library is a helper for Vapor 3 projects to validate form submissions using the Google reCAPTCHA platform.

To get started, you need to obtain a secret key from: https://www.google.com/recaptcha/admin

Installation

Vapor reCAPTCHA is available through SPM. To install it, simply add the following to your Package.swift file:

.package(url: "https://github.com/gotranseo/vapor-recaptcha.git", from: "1.0.0")

Don't forget to also add it to dependencies array.

Usage

Registering the Provider

In configure.swift, add this line:

let captchaConfig = CaptchaConfig(secretKey: "SECRET-KEY-FROM-GOOGLE")
services.register(CaptchaProvider(config: captchaConfig))

Usage

In your controller, you can do something like this:

let captchaResponse = ... //value from a submitted form
let googleCaptcha = try req.make(Captcha.self)
return googleCaptcha.validate(captchaFormResponse: captchaResponse).flatMap { success in 
    if success {
        //celebrate!
    } else {
        // :(
    }
}

Author

Slate Solutions, Inc.

License

Vapor reCAPTCHA is available under the MIT license. See the LICENSE file for more info.

Description

  • Swift Tools 4.0.0
View More Packages from this Author

Dependencies

Last updated: Fri Apr 19 2024 12:59:00 GMT-0900 (Hawaii-Aleutian Daylight Time)