Files
Atay-Makhzan/modules/context/captcha.go
T

29 lines
611 B
Go
Raw Normal View History

2021-01-26 23:36:53 +08:00
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package context
import (
"sync"
2021-01-27 22:56:54 +08:00
"code.gitea.io/gitea/modules/cache"
2021-01-26 23:36:53 +08:00
"code.gitea.io/gitea/modules/setting"
"gitea.com/go-chi/captcha"
)
var imageCaptchaOnce sync.Once
var cpt *captcha.Captcha
// GetImageCaptcha returns global image captcha
func GetImageCaptcha() *captcha.Captcha {
imageCaptchaOnce.Do(func() {
cpt = captcha.NewCaptcha(captcha.Options{
SubURL: setting.AppSubURL,
})
2021-01-27 22:56:54 +08:00
cpt.Store = cache.GetCache()
2021-01-26 23:36:53 +08:00
})
return cpt
}