mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 21:30:24 +08:00
feat: add user's MFA items (#3921)
This commit is contained in:
@ -536,7 +536,13 @@ func IsNeedPromptMfa(org *Organization, user *User) bool {
|
||||
if org == nil || user == nil {
|
||||
return false
|
||||
}
|
||||
for _, item := range org.MfaItems {
|
||||
|
||||
mfaItems := org.MfaItems
|
||||
|
||||
if len(user.MfaItems) > 0 {
|
||||
mfaItems = user.MfaItems
|
||||
}
|
||||
for _, item := range mfaItems {
|
||||
if item.Rule == "Required" {
|
||||
if item.Name == EmailType && !user.MfaEmailEnabled {
|
||||
return true
|
||||
|
@ -212,6 +212,7 @@ type User struct {
|
||||
|
||||
ManagedAccounts []ManagedAccount `xorm:"managedAccounts blob" json:"managedAccounts"`
|
||||
MfaAccounts []MfaAccount `xorm:"mfaAccounts blob" json:"mfaAccounts"`
|
||||
MfaItems []*MfaItem `xorm:"varchar(300)" json:"mfaItems"`
|
||||
NeedUpdatePassword bool `json:"needUpdatePassword"`
|
||||
IpWhitelist string `xorm:"varchar(200)" json:"ipWhitelist"`
|
||||
}
|
||||
@ -795,7 +796,7 @@ func UpdateUser(id string, user *User, columns []string, isAdmin bool) (bool, er
|
||||
}
|
||||
}
|
||||
if isAdmin {
|
||||
columns = append(columns, "name", "id", "email", "phone", "country_code", "type", "balance")
|
||||
columns = append(columns, "name", "id", "email", "phone", "country_code", "type", "balance", "mfa_items")
|
||||
}
|
||||
|
||||
columns = append(columns, "updated_time")
|
||||
|
Reference in New Issue
Block a user