mirror of
https://github.com/VaalaCat/frp-panel.git
synced 2026-04-22 23:17:23 +08:00
25 lines
590 B
Go
25 lines
590 B
Go
package auth
|
|
|
|
import (
|
|
"github.com/VaalaCat/frp-panel/cache"
|
|
"github.com/VaalaCat/frp-panel/dao"
|
|
"github.com/VaalaCat/frp-panel/models"
|
|
"github.com/samber/lo"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func InitAuth() {
|
|
logrus.Info("start to init frp user auth token")
|
|
|
|
u, err := dao.AdminGetAllUsers()
|
|
if err != nil {
|
|
logrus.WithError(err).Fatalf("init frp user auth token failed")
|
|
}
|
|
|
|
lo.ForEach(u, func(user *models.UserEntity, _ int) {
|
|
cache.Get().Set([]byte(user.GetUserName()), []byte(user.GetToken()), 0)
|
|
})
|
|
|
|
logrus.Infof("init frp user auth token success, count: %d", len(u))
|
|
}
|