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

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

@ -5,10 +5,8 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="19c8c37d-a056-451c-a29d-fb612b9a3e2f" name="Default Changelist" comment="commit"> <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$/.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$/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> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -68,14 +66,6 @@
</key> </key>
</component> </component>
<component name="RunManager" selected="Go Build.go build dsSzxy"> <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"> <configuration name="go build dsSzxy" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="dsSzxy" /> <module name="dsSzxy" />
<working_directory value="$PROJECT_DIR$" /> <working_directory value="$PROJECT_DIR$" />
@ -94,15 +84,6 @@
<filePath value="$PROJECT_DIR$/main.go" /> <filePath value="$PROJECT_DIR$/main.go" />
<method v="2" /> <method v="2" />
</configuration> </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> <recent_temporary>
<list> <list>
<item itemvalue="Go Build.go build dsSzxy" /> <item itemvalue="Go Build.go build dsSzxy" />

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

Loading…
Cancel
Save