commit
continuous-integration/drone/push Build is passing Details

master
黄海 4 years ago
parent 52fd93ef04
commit 3323767dad

@ -5,10 +5,8 @@
</component>
<component name="ChangeListManager">
<list default="true" id="19c8c37d-a056-451c-a29d-fb612b9a3e2f" name="Default Changelist" comment="commit">
<change afterPath="$PROJECT_DIR$/Business/CaptchaRelate/CaptchaController/RedisStore.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Business/CaptchaRelate/CaptchaController/CaptchaController.go" beforeDir="false" afterPath="$PROJECT_DIR$/Business/CaptchaRelate/CaptchaController/CaptchaController.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/static/getcapt.html" beforeDir="false" afterPath="$PROJECT_DIR$/static/getcapt.html" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -68,14 +66,6 @@
</key>
</component>
<component name="RunManager" selected="Go Build.go build dsSzxy">
<configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="dsSzxy" />
<working_directory value="$PROJECT_DIR$" />
<kind value="FILE" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="go build dsSzxy" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="dsSzxy" />
<working_directory value="$PROJECT_DIR$" />
@ -94,15 +84,6 @@
<filePath value="$PROJECT_DIR$/main.go" />
<method v="2" />
</configuration>
<configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
<module name="dsSzxy" />
<working_directory value="$PROJECT_DIR$" />
<kind value="DIRECTORY" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Go Build.go build dsSzxy" />

@ -6,7 +6,6 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/mojocn/base64Captcha"
"image/color"
"net/http"
)
@ -31,10 +30,7 @@ type CaptchaResult struct {
// GetOne 生成图形化验证码
func getCaptcha(c *gin.Context) {
id, b64s, err := CaptMake()
if err != nil {
c.JSON(http.StatusOK, gin.H{"success": false, "info": "发生错误!"})
}
id, b64s := CaptMake()
captchaResult := CaptchaResult{
Id: id,
Base64Blob: b64s,
@ -59,31 +55,18 @@ func verifyCaptcha(c *gin.Context) {
}
// CaptMake 生成验证码
func CaptMake() (id, b64s string, err error) {
var driver base64Captcha.Driver
var driverString base64Captcha.DriverString
// 配置验证码信息
captchaConfig := base64Captcha.DriverString{
Height: 60,
Width: 200,
NoiseCount: 0,
ShowLineOptions: 2 | 4,
Length: 4,
Source: "1234567890qwertyuioplkjhgfdsazxcvbnm",
BgColor: &color.RGBA{
R: 3,
G: 102,
B: 214,
A: 125,
},
Fonts: []string{"wqy-microhei.ttc"},
func CaptMake() (string, string) {
// 生成默认数字
driver := base64Captcha.DefaultDriverDigit
// 生成base64图片
c := base64Captcha.NewCaptcha(driver, store)
// 获取
id, b64s, err := c.Generate()
if err != nil {
fmt.Println("Register GetCaptchaPhoto get base64Captcha has err:", err)
return "", ""
}
driverString = captchaConfig
driver = driverString.ConvertFonts()
captcha := base64Captcha.NewCaptcha(driver, store)
lid, lb64s, lerr := captcha.Generate()
return lid, lb64s, lerr
return id, b64s
}
// CaptVerify 验证captcha是否正确

Loading…
Cancel
Save