MCPcopy
hub / github.com/koderover/zadig / GetCaptcha

Function GetCaptcha

pkg/microservice/user/core/service/login/local.go:422–439  ·  view source on GitHub ↗
(account string, logger *zap.SugaredLogger)

Source from the content-addressed store, hash-verified

420var store = base64Captcha.DefaultMemStore
421
422func GetCaptcha(account string, logger *zap.SugaredLogger) (string, string, error) {
423 account = strings.TrimSpace(account)
424 if account == "" {
425 return "", "", fmt.Errorf("account is required")
426 }
427
428 driver := base64Captcha.DefaultDriverDigit
429
430 c := base64Captcha.NewCaptcha(driver, store)
431 id, b64s, err := c.Generate()
432 if err != nil {
433 logger.Errorf("failed to generate captcha, error: %s", err)
434 return "", "", fmt.Errorf("captcha generate error")
435 }
436
437 captchaAccountCache.Set(id, account, base64Captcha.Expiration)
438 return id, b64s, nil
439}

Callers 1

GetCaptchaFunction · 0.92

Calls 2

SetMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected