feat ✨ 验证码store支持go-admin cache
This commit is contained in:
1 parent
e034e5b1ea
commit
eddfe26308
5 files changed
+12
-6
No files matched your search
+1
-1
@@ -23,4 +23,4 @@ COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["/go-admin","server","-c", "/config/settings.yml"]
|
||||
CMD ["/go-admin","server","-c", "/config/settings.yml"]
|
||||
+5
-1
@@ -3,6 +3,8 @@ package api
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/go-admin-team/go-admin-core/tools/captcha"
|
||||
"go-admin/common/middleware/handler"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -71,6 +73,8 @@ func setup() {
|
||||
log.Fatalf("cache setup error, %s\n", err.Error())
|
||||
}
|
||||
sdk.Runtime.SetCacheAdapter(cacheAdapter)
|
||||
//5. 设置验证码store
|
||||
handler.SetStore(captcha.NewCacheStore(cacheAdapter, 600))
|
||||
|
||||
usageStr := `starting api server...`
|
||||
log.Println(usageStr)
|
||||
@@ -150,4 +154,4 @@ func run() error {
|
||||
func tip() {
|
||||
usageStr := `欢迎使用 ` + pkg.Green(`go-admin `+global.Version) + ` 可以使用 ` + pkg.Red(`-h`) + ` 查看命令`
|
||||
fmt.Printf("%s \n\n", usageStr)
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,11 @@ import (
|
||||
|
||||
var store = base64Captcha.DefaultMemStore
|
||||
|
||||
// SetStore 设置store
|
||||
func SetStore(s base64Captcha.Store) {
|
||||
store = s
|
||||
}
|
||||
|
||||
func PayloadFunc(data interface{}) jwt.MapClaims {
|
||||
if v, ok := data.(map[string]interface{}); ok {
|
||||
u, _ := v["user"].(SysUser)
|
||||
|
||||
@@ -8,7 +8,7 @@ require (
|
||||
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5
|
||||
github.com/casbin/casbin/v2 v2.25.1
|
||||
github.com/gin-gonic/gin v1.6.3
|
||||
github.com/go-admin-team/go-admin-core v1.3.4-0.20210331124757-4c4d0bf6c336
|
||||
github.com/go-admin-team/go-admin-core v1.3.0-rc.0.0.20210407093008-7e27bec63f3e
|
||||
github.com/google/uuid v1.2.0
|
||||
github.com/mojocn/base64Captcha v1.3.1
|
||||
github.com/mssola/user_agent v0.5.2
|
||||
|
||||
@@ -3,7 +3,6 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: go-admin
|
||||
namespace: go-admin
|
||||
labels:
|
||||
app: go-admin
|
||||
service: go-admin
|
||||
@@ -19,7 +18,6 @@ apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: go-admin-v1
|
||||
namespace: go-admin
|
||||
labels:
|
||||
app: go-admin
|
||||
version: v1
|
||||
@@ -35,7 +33,6 @@ spec:
|
||||
app: go-admin
|
||||
version: v1
|
||||
spec:
|
||||
serviceAccountName: go-admin-go-admin
|
||||
containers:
|
||||
- name: go-admin
|
||||
image: ${IMAGE}
|
||||
|
||||
Reference in new issue
Block a user