fix: update config management in account pkg
This commit is contained in:
parent
856b7fb627
commit
7f5741a64b
|
@ -5,8 +5,9 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.lumeweb.com/LumeWeb/portal/config"
|
||||||
|
|
||||||
"git.lumeweb.com/LumeWeb/portal/db/models"
|
"git.lumeweb.com/LumeWeb/portal/db/models"
|
||||||
"github.com/spf13/viper"
|
|
||||||
"go.uber.org/fx"
|
"go.uber.org/fx"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -19,7 +20,7 @@ var (
|
||||||
type AccountServiceParams struct {
|
type AccountServiceParams struct {
|
||||||
fx.In
|
fx.In
|
||||||
Db *gorm.DB
|
Db *gorm.DB
|
||||||
Config *viper.Viper
|
Config *config.Manager
|
||||||
Identity ed25519.PrivateKey
|
Identity ed25519.PrivateKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ var Module = fx.Module("account",
|
||||||
|
|
||||||
type AccountServiceDefault struct {
|
type AccountServiceDefault struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
config *viper.Viper
|
config *config.Manager
|
||||||
identity ed25519.PrivateKey
|
identity ed25519.PrivateKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +150,7 @@ func (s AccountServiceDefault) LoginOTP(userId uint, code string) (string, error
|
||||||
var user models.User
|
var user models.User
|
||||||
user.ID = userId
|
user.ID = userId
|
||||||
|
|
||||||
token, tokenErr := JWTGenerateToken(s.config.GetString("core.domain"), s.identity, user.ID, JWTPurposeLogin)
|
token, tokenErr := JWTGenerateToken(s.config.Config().Core.Domain, s.identity, user.ID, JWTPurposeLogin)
|
||||||
if tokenErr != nil {
|
if tokenErr != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -325,7 +326,7 @@ func (s AccountServiceDefault) OTPGenerate(userId uint) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
otp, otpErr := TOTPGenerate(user.Email, s.config.GetString("core.domain"))
|
otp, otpErr := TOTPGenerate(user.Email, s.config.Config().Core.Domain)
|
||||||
if otpErr != nil {
|
if otpErr != nil {
|
||||||
return "", NewAccountError(ErrKeyOTPGenerationFailed, otpErr)
|
return "", NewAccountError(ErrKeyOTPGenerationFailed, otpErr)
|
||||||
}
|
}
|
||||||
|
@ -373,7 +374,7 @@ func (s AccountServiceDefault) doLogin(user *models.User, ip string) (string, er
|
||||||
purpose = JWTPurpose2FA
|
purpose = JWTPurpose2FA
|
||||||
}
|
}
|
||||||
|
|
||||||
token, jwtErr := JWTGenerateToken(s.config.GetString("core.domain"), s.identity, user.ID, purpose)
|
token, jwtErr := JWTGenerateToken(s.config.Config().Core.Domain, s.identity, user.ID, purpose)
|
||||||
if jwtErr != nil {
|
if jwtErr != nil {
|
||||||
return "", NewAccountError(ErrKeyJWTGenerationFailed, jwtErr)
|
return "", NewAccountError(ErrKeyJWTGenerationFailed, jwtErr)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue