提交 v1.3.0-beta2
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"next-terminal/server/common"
|
||||
"next-terminal/server/common/maps"
|
||||
"next-terminal/server/common/nt"
|
||||
"path"
|
||||
"strings"
|
||||
@ -90,7 +91,34 @@ func (api AccountApi) LoginEndpoint(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return Success(c, token)
|
||||
var menus []string
|
||||
if service.UserService.IsSuperAdmin(user.ID) {
|
||||
menus = service.MenuService.GetMenus()
|
||||
} else {
|
||||
roles, err := service.RoleService.GetRolesByUserId(user.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, role := range roles {
|
||||
items := service.RoleService.GetMenuListByRole(role)
|
||||
menus = append(menus, items...)
|
||||
}
|
||||
}
|
||||
|
||||
info := AccountInfo{
|
||||
Id: user.ID,
|
||||
Username: user.Username,
|
||||
Nickname: user.Nickname,
|
||||
Type: user.Type,
|
||||
EnableTotp: user.TOTPSecret != "" && user.TOTPSecret != "-",
|
||||
Roles: user.Roles,
|
||||
Menus: menus,
|
||||
}
|
||||
|
||||
return Success(c, maps.Map{
|
||||
"info": info,
|
||||
"token": token,
|
||||
})
|
||||
}
|
||||
|
||||
func (api AccountApi) LoginSuccess(loginAccount dto.LoginAccount, user model.User, ip string) (string, error) {
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
type CredentialApi struct{}
|
||||
|
||||
func (api CredentialApi) CredentialAllEndpoint(c echo.Context) error {
|
||||
items, err := repository.CredentialRepository.FindByAll(context.TODO())
|
||||
items, err := repository.CredentialRepository.FindByAll(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -76,6 +76,10 @@ func (app App) InitDBData() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := service.MigrateService.Migrate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ func setupRoutes() *echo.Echo {
|
||||
|
||||
credentials := e.Group("/credentials", mw.Admin)
|
||||
{
|
||||
//credentials.GET("", CredentialApi.CredentialAllEndpoint)
|
||||
credentials.GET("", CredentialApi.CredentialAllEndpoint)
|
||||
credentials.GET("/paging", CredentialApi.CredentialPagingEndpoint)
|
||||
credentials.POST("", CredentialApi.CredentialCreateEndpoint)
|
||||
credentials.PUT("/:id", CredentialApi.CredentialUpdateEndpoint)
|
||||
|
@ -9,5 +9,5 @@ var Banner = ` ___ ___
|
||||
\/|::/ / /:/\/__/
|
||||
|:/ / \/__/
|
||||
\/__/ `
|
||||
var Version = `v1.3.0-beta1`
|
||||
var Version = `v1.3.0-beta2`
|
||||
var Hi = Banner + Version
|
||||
|
@ -149,3 +149,7 @@ func Fatal(msg string, fields ...Field) {
|
||||
func Sync() error {
|
||||
return _logger.Sync()
|
||||
}
|
||||
|
||||
func GetLogger() *zap.Logger {
|
||||
return _logger
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func (r authorisedRepository) FindByUserId(c context.Context, userId string) (it
|
||||
}
|
||||
|
||||
func (r authorisedRepository) FindById(c context.Context, id string) (item model.Authorised, err error) {
|
||||
err = r.GetDB(c).Where("id = ?", id).Find(&item).Error
|
||||
err = r.GetDB(c).Where("id = ?", id).First(&item).Error
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,6 @@ func (r commandRepository) FindAll(c context.Context) (o []model.Command, err er
|
||||
}
|
||||
|
||||
func (r commandRepository) FindByUserId(c context.Context, userId string) (o []model.Command, err error) {
|
||||
err = r.GetDB(c).Where("owner = ?", userId).First(&o).Error
|
||||
err = r.GetDB(c).Where("owner = ?", userId).Find(&o).Error
|
||||
return
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ MainLoop:
|
||||
}
|
||||
|
||||
func (gui Gui) AssetUI(sess ssh.Session, user model.User) {
|
||||
assets, err := service.WorkerService.FindMyAsset("", nt.SSH, "", "", "", "")
|
||||
assets, err := service.WorkerService.FindMyAsset("", nt.SSH, "", user.ID, "", "")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import (
|
||||
"crypto/sha512"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
|
||||
"github.com/denisbrodbeck/machineid"
|
||||
)
|
||||
|
||||
// SignatureRSA rsa私钥签名
|
||||
@ -46,3 +48,7 @@ func VerifyRSA(plainText, signText []byte, rsaPublicKey string) bool {
|
||||
err = rsa.VerifyPKCS1v15(publicKey, crypto.SHA512, hashText[:], signText)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func GetMachineId() (string, error) {
|
||||
return machineid.ID()
|
||||
}
|
||||
|
Reference in New Issue
Block a user