Merge branch 'dev' of https://github.com/go-admin-team/go-admin into dev
This commit is contained in:
commit
a10bacc1f5
4 files changed
+39
-4
No files matched your search
@@ -61,7 +61,7 @@ func IdentityHandler(c *gin.Context) interface{} {
|
|||||||
// @Router /login [post]
|
// @Router /login [post]
|
||||||
func Authenticator(c *gin.Context) (interface{}, error) {
|
func Authenticator(c *gin.Context) (interface{}, error) {
|
||||||
var loginVals models.Login
|
var loginVals models.Login
|
||||||
var status = "0"
|
var status = "2"
|
||||||
var msg = "登录成功"
|
var msg = "登录成功"
|
||||||
var username = ""
|
var username = ""
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ func LogOut(c *gin.Context) {
|
|||||||
location := tools.GetLocation(c.ClientIP())
|
location := tools.GetLocation(c.ClientIP())
|
||||||
loginLog.LoginLocation = location
|
loginLog.LoginLocation = location
|
||||||
loginLog.LoginTime = tools.GetCurrentTime()
|
loginLog.LoginTime = tools.GetCurrentTime()
|
||||||
loginLog.Status = "0"
|
loginLog.Status = "2"
|
||||||
loginLog.Remark = c.Request.UserAgent()
|
loginLog.Remark = c.Request.UserAgent()
|
||||||
browserName, browserVersion := ua.Browser()
|
browserName, browserVersion := ua.Browser()
|
||||||
loginLog.Browser = browserName + " " + browserVersion
|
loginLog.Browser = browserName + " " + browserVersion
|
||||||
|
|||||||
@@ -28,14 +28,17 @@ func AuthCheckRole() gin.HandlerFunc {
|
|||||||
} else {
|
} else {
|
||||||
res, err = e.Enforce(v["rolekey"], c.Request.URL.Path, c.Request.Method)
|
res, err = e.Enforce(v["rolekey"], c.Request.URL.Path, c.Request.Method)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("msgID[%s] error:%s method:%s path:%s", msgID, err, c.Request.Method, c.Request.URL.Path)
|
log.Errorf("msgID[%s] AuthCheckRole error:%s method:%s path:%s", msgID, err, c.Request.Method, c.Request.URL.Path)
|
||||||
app.Error(c, 500, err, "")
|
app.Error(c, 500, err, "")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res {
|
if res {
|
||||||
|
log.Infof("msgID[%s] isTrue: %v role: %s method: %s path: %s", msgID, res, v["rolekey"], c.Request.Method, c.Request.URL.Path)
|
||||||
c.Next()
|
c.Next()
|
||||||
} else {
|
} else {
|
||||||
|
log.Warnf("msgID[%s] isTrue: %v role: %s method: %s path: %s message: %s", msgID, res, v["rolekey"], c.Request.Method, c.Request.URL.Path,"当前request无权限,请管理员确认!")
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 403,
|
"code": 403,
|
||||||
"msg": "对不起,您没有该接口访问权限,请联系管理员",
|
"msg": "对不起,您没有该接口访问权限,请联系管理员",
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func _1599190683670Test(db *gorm.DB, version string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
list8 := []models.SysUser{
|
list8 := []models.SysUser{
|
||||||
{models.SysUserId{1}, models.LoginM{models.UserName{"admin"}, models.PassWord{"$2a$10$cKFFTCzGOvaIHHJY2K45Zuwt8TD6oPzYi4s5MzYIBAWCLL6ZhouP2"}}, models.SysUserB{"zhangwj", "13818888888", 1, "", "", "0", "1@qq.com", 1, 1, "1", "1", "", "0", models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}, "", ""}},
|
{models.SysUserId{1}, models.LoginM{models.UserName{"admin"}, models.PassWord{"$2a$10$cKFFTCzGOvaIHHJY2K45Zuwt8TD6oPzYi4s5MzYIBAWCLL6ZhouP2"}}, models.SysUserB{"zhangwj", "13818888888", 1, "", "", "0", "1@qq.com", 1, 1, "1", "1", "", "2", models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}, "", ""}},
|
||||||
}
|
}
|
||||||
|
|
||||||
list9 := []models.DictData{
|
list9 := []models.DictData{
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go-admin/app/admin/models"
|
||||||
|
//"go-admin/app/admin/models"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
|
"go-admin/cmd/migrate/migration"
|
||||||
|
common "go-admin/common/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
_, fileName, _, _ := runtime.Caller(0)
|
||||||
|
migration.Migrate.SetVersion(migration.GetFilename(fileName), _1610427732413Test)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _1610427732413Test(db *gorm.DB, version string) error {
|
||||||
|
return db.Transaction(func(tx *gorm.DB) error {
|
||||||
|
|
||||||
|
// TODO: 这里开始写入要变更的内容
|
||||||
|
user := models.SysUser{}
|
||||||
|
err := tx.Model(&user).Where("status = ?", 0).Update("status", 2).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return tx.Create(&common.Migration{
|
||||||
|
Version: version,
|
||||||
|
}).Error
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in new issue
Block a user