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