mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-02 07:20:24 +08:00
chore: 处理合并问题
This commit is contained in:
@@ -24,7 +24,10 @@ require (
|
||||
gorm.io/gorm v1.25.2
|
||||
)
|
||||
|
||||
require github.com/go-gormigrate/gormigrate/v2 v2.1.0
|
||||
require (
|
||||
github.com/go-gormigrate/gormigrate/v2 v2.1.0
|
||||
golang.org/x/oauth2 v0.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
|
||||
@@ -63,7 +66,6 @@ require (
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/image v0.0.0-20220302094943-723b81ca9867 // indirect
|
||||
golang.org/x/net v0.12.0 // indirect
|
||||
golang.org/x/oauth2 v0.10.0 // indirect
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sys v0.10.0 // indirect
|
||||
golang.org/x/text v0.11.0 // indirect
|
||||
|
||||
@@ -120,7 +120,7 @@ func useOtp(account *entity.Account, otpIssuer, accessToken string) (*OtpVerifyI
|
||||
otpStatus := OtpStatusReg
|
||||
otpUrl := ""
|
||||
// 该token用于otp双因素校验
|
||||
token := utils.RandString(32)
|
||||
token := stringx.Rand(32)
|
||||
// 未注册otp secret或重置了秘钥
|
||||
if otpSecret == "" || otpSecret == "-" {
|
||||
otpStatus = OtpStatusNoReg
|
||||
@@ -140,7 +140,7 @@ func useOtp(account *entity.Account, otpIssuer, accessToken string) (*OtpVerifyI
|
||||
OtpSecret: otpSecret,
|
||||
AccessToken: accessToken,
|
||||
}
|
||||
cache.SetStr(fmt.Sprintf("otp:token:%s", token), utils.ToJsonStr(otpInfo), time.Minute*time.Duration(3))
|
||||
cache.SetStr(fmt.Sprintf("otp:token:%s", token), jsonx.ToStr(otpInfo), time.Minute*time.Duration(3))
|
||||
return otpInfo, otpUrl, token
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"mayfly-go/pkg/global"
|
||||
"mayfly-go/pkg/model"
|
||||
"mayfly-go/pkg/req"
|
||||
"mayfly-go/pkg/utils"
|
||||
"mayfly-go/pkg/utils/stringx"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -53,7 +53,7 @@ func (a *Auth) OAuth2Login(rc *req.Ctx) {
|
||||
biz.ErrIsNil(err, "获取oauth2 client失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
state := utils.RandString(32)
|
||||
state := stringx.Rand(32)
|
||||
cache.SetStr("oauth2:state:"+state, "login", 5*time.Minute)
|
||||
rc.GinCtx.Redirect(http.StatusFound, client.AuthCodeURL(state))
|
||||
}
|
||||
@@ -155,7 +155,7 @@ func (a *Auth) OAuth2Callback(rc *req.Ctx) {
|
||||
}
|
||||
// 进行登录
|
||||
account := &entity.Account{
|
||||
Model: model.Model{Id: accountId},
|
||||
Model: model.Model{DeletedModel: model.DeletedModel{Id: accountId}},
|
||||
}
|
||||
if err := a.AccountApp.GetAccount(account, "Id", "Name", "Username", "Password", "Status", "LastLoginTime", "LastLoginIp", "OtpSecret"); err != nil {
|
||||
biz.ErrIsNil(err, "获取用户信息失败: "+err.Error())
|
||||
@@ -305,7 +305,7 @@ func (a *Auth) OAuth2Bind(rc *req.Ctx) {
|
||||
biz.ErrIsNil(err, "获取oauth2 client失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
state := utils.RandString(32)
|
||||
state := stringx.Rand(32)
|
||||
cache.SetStr("oauth2:state:"+state, "bind:"+strconv.FormatUint(rc.LoginAccount.Id, 10),
|
||||
5*time.Minute)
|
||||
rc.GinCtx.Redirect(http.StatusFound, client.AuthCodeURL(state))
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"mayfly-go/pkg/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type OAuthAccount struct {
|
||||
Id uint64 `json:"id"`
|
||||
model.DeletedModel
|
||||
|
||||
AccountId uint64 `json:"accountId" gorm:"column:account_id;index:account_id,unique"`
|
||||
Identity string `json:"identity" gorm:"column:identity;index:identity,unique"`
|
||||
|
||||
@@ -18,13 +18,13 @@ func T20230720() *gormigrate.Migration {
|
||||
now := time.Now()
|
||||
res := &entity.Resource{
|
||||
Model: model.Model{
|
||||
Id: 130,
|
||||
CreateTime: &now,
|
||||
CreatorId: 1,
|
||||
Creator: "admin",
|
||||
UpdateTime: &now,
|
||||
ModifierId: 1,
|
||||
Modifier: "admin",
|
||||
DeletedModel: model.DeletedModel{Id: 130},
|
||||
CreateTime: &now,
|
||||
CreatorId: 1,
|
||||
Creator: "admin",
|
||||
UpdateTime: &now,
|
||||
ModifierId: 1,
|
||||
Modifier: "admin",
|
||||
},
|
||||
Pid: 4,
|
||||
UiPath: "sys/auth",
|
||||
@@ -42,13 +42,13 @@ func T20230720() *gormigrate.Migration {
|
||||
}
|
||||
res = &entity.Resource{
|
||||
Model: model.Model{
|
||||
Id: 131,
|
||||
CreateTime: &now,
|
||||
CreatorId: 1,
|
||||
Creator: "admin",
|
||||
UpdateTime: &now,
|
||||
ModifierId: 1,
|
||||
Modifier: "admin",
|
||||
DeletedModel: model.DeletedModel{Id: 131},
|
||||
CreateTime: &now,
|
||||
CreatorId: 1,
|
||||
Creator: "admin",
|
||||
UpdateTime: &now,
|
||||
ModifierId: 1,
|
||||
Modifier: "admin",
|
||||
},
|
||||
Pid: 130,
|
||||
UiPath: "sys/auth/base",
|
||||
|
||||
Reference in New Issue
Block a user