refactor: add bypassSecurity to doLogin

This commit is contained in:
Derrick Hammer 2024-02-26 08:26:59 -05:00
parent b270d6f414
commit 2573936000
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 4 deletions

View File

@ -201,7 +201,7 @@ func (s AccountServiceDefault) LoginPassword(email string, password string, ip s
return "", nil, nil
}
token, err := s.doLogin(user, ip)
token, err := s.doLogin(user, ip, false)
if err != nil {
return "", nil, err
@ -297,7 +297,7 @@ func (s AccountServiceDefault) LoginPubkey(pubkey string) (string, error) {
user := model.User
token, err := s.doLogin(&user, "")
token, err := s.doLogin(&user, "", true)
if err != nil {
return "", err
@ -463,10 +463,10 @@ func GenerateSecurityToken() string {
return string(b)
}
func (s AccountServiceDefault) doLogin(user *models.User, ip string) (string, error) {
func (s AccountServiceDefault) doLogin(user *models.User, ip string, bypassSecurity bool) (string, error) {
purpose := JWTPurposeLogin
if user.OTPEnabled {
if user.OTPEnabled && !bypassSecurity {
purpose = JWTPurpose2FA
}