1
0

Add option to disable totp for everyone

This commit is contained in:
kolaente
2020-05-29 17:15:59 +02:00
parent a0fb8bd32d
commit 5a04f1ecf4
6 changed files with 20 additions and 5 deletions

View File

@ -17,6 +17,7 @@
package user
import (
"code.vikunja.io/api/pkg/config"
"github.com/pquerna/otp"
"github.com/pquerna/otp/totp"
"image"
@ -46,6 +47,9 @@ type TOTPPasscode struct {
// TOTPEnabledForUser checks if totp is enabled for a user - not if it is activated, use GetTOTPForUser to check that.
func TOTPEnabledForUser(user *User) (bool, error) {
if !config.ServiceEnableTotp.GetBool() {
return false, nil
}
return x.Where("user_id = ?", user.ID).Exist(&TOTP{})
}