增加批量导入资产功能

This commit is contained in:
dushixiang
2021-03-09 23:52:44 +08:00
parent b48f650f7e
commit dc9934bc9e
16 changed files with 273 additions and 23 deletions

View File

@ -91,7 +91,7 @@ func LoginSuccess(c echo.Context, loginAccount LoginAccount, user model.User) (t
User: user,
}
cacheKey := strings.Join([]string{Token, token}, ":")
cacheKey := BuildCacheKeyByToken(token)
if authorization.Remember {
// 记住登录有效期两周
@ -119,6 +119,16 @@ func LoginSuccess(c echo.Context, loginAccount LoginAccount, user model.User) (t
return token, nil
}
func BuildCacheKeyByToken(token string) string {
cacheKey := strings.Join([]string{Token, token}, ":")
return cacheKey
}
func GetTokenFormCacheKey(cacheKey string) string {
token := strings.Split(cacheKey, ":")[1]
return token
}
func loginWithTotpEndpoint(c echo.Context) error {
var loginAccount LoginAccount
if err := c.Bind(&loginAccount); err != nil {
@ -165,7 +175,7 @@ func loginWithTotpEndpoint(c echo.Context) error {
func LogoutEndpoint(c echo.Context) error {
token := GetToken(c)
cacheKey := strings.Join([]string{Token, token}, ":")
cacheKey := BuildCacheKeyByToken(token)
global.Cache.Delete(cacheKey)
model.Logout(token)
return Success(c, nil)