feat ✨ 验证码store支持go-admin cache
This commit is contained in:
1 parent
e034e5b1ea
commit
eddfe26308
4 files changed
+10
-4
No files matched your search
@@ -3,6 +3,8 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/go-admin-team/go-admin-core/tools/captcha"
|
||||||
|
"go-admin/common/middleware/handler"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -71,6 +73,8 @@ func setup() {
|
|||||||
log.Fatalf("cache setup error, %s\n", err.Error())
|
log.Fatalf("cache setup error, %s\n", err.Error())
|
||||||
}
|
}
|
||||||
sdk.Runtime.SetCacheAdapter(cacheAdapter)
|
sdk.Runtime.SetCacheAdapter(cacheAdapter)
|
||||||
|
//5. 设置验证码store
|
||||||
|
handler.SetStore(captcha.NewCacheStore(cacheAdapter, 600))
|
||||||
|
|
||||||
usageStr := `starting api server...`
|
usageStr := `starting api server...`
|
||||||
log.Println(usageStr)
|
log.Println(usageStr)
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ import (
|
|||||||
|
|
||||||
var store = base64Captcha.DefaultMemStore
|
var store = base64Captcha.DefaultMemStore
|
||||||
|
|
||||||
|
// SetStore 设置store
|
||||||
|
func SetStore(s base64Captcha.Store) {
|
||||||
|
store = s
|
||||||
|
}
|
||||||
|
|
||||||
func PayloadFunc(data interface{}) jwt.MapClaims {
|
func PayloadFunc(data interface{}) jwt.MapClaims {
|
||||||
if v, ok := data.(map[string]interface{}); ok {
|
if v, ok := data.(map[string]interface{}); ok {
|
||||||
u, _ := v["user"].(SysUser)
|
u, _ := v["user"].(SysUser)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ require (
|
|||||||
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5
|
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5
|
||||||
github.com/casbin/casbin/v2 v2.25.1
|
github.com/casbin/casbin/v2 v2.25.1
|
||||||
github.com/gin-gonic/gin v1.6.3
|
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/google/uuid v1.2.0
|
||||||
github.com/mojocn/base64Captcha v1.3.1
|
github.com/mojocn/base64Captcha v1.3.1
|
||||||
github.com/mssola/user_agent v0.5.2
|
github.com/mssola/user_agent v0.5.2
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ apiVersion: v1
|
|||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: go-admin
|
name: go-admin
|
||||||
namespace: go-admin
|
|
||||||
labels:
|
labels:
|
||||||
app: go-admin
|
app: go-admin
|
||||||
service: go-admin
|
service: go-admin
|
||||||
@@ -19,7 +18,6 @@ apiVersion: apps/v1
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: go-admin-v1
|
name: go-admin-v1
|
||||||
namespace: go-admin
|
|
||||||
labels:
|
labels:
|
||||||
app: go-admin
|
app: go-admin
|
||||||
version: v1
|
version: v1
|
||||||
@@ -35,7 +33,6 @@ spec:
|
|||||||
app: go-admin
|
app: go-admin
|
||||||
version: v1
|
version: v1
|
||||||
spec:
|
spec:
|
||||||
serviceAccountName: go-admin-go-admin
|
|
||||||
containers:
|
containers:
|
||||||
- name: go-admin
|
- name: go-admin
|
||||||
image: ${IMAGE}
|
image: ${IMAGE}
|
||||||
|
|||||||
Reference in new issue
Block a user