mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2026-11-03 03:31:58 +08:00
39 lines
1018 B
Go
39 lines
1018 B
Go
package wafdb
|
|
|
|
import (
|
|
"SamWaf/customtype"
|
|
"SamWaf/global"
|
|
"SamWaf/model"
|
|
"SamWaf/utils"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// ResetAdminPwd 重置密码
|
|
func ResetAdminPwd() {
|
|
defaultAcount := "admin"
|
|
randomPassword, _ := utils.GenerateRandomPassword(12)
|
|
beanMap := map[string]interface{}{
|
|
"LoginPassword": utils.Md5String(randomPassword + global.GWAF_DEFAULT_ACCOUNT_SALT),
|
|
"UPDATE_TIME": customtype.JsonTime(time.Now()),
|
|
}
|
|
err := global.GWAF_LOCAL_DB.Model(model.Account{}).Where(" login_account = ?", defaultAcount).Updates(beanMap).Error
|
|
if err != nil {
|
|
|
|
} else {
|
|
err = global.GWAF_LOCAL_DB.Where("login_account = ? ", defaultAcount).Delete(model.TokenInfo{}).Error
|
|
|
|
fmt.Println("Reset password is success,the new password is :")
|
|
fmt.Println(randomPassword)
|
|
fmt.Println("Please keep it safe.")
|
|
}
|
|
|
|
}
|
|
|
|
// ResetAdminOTP 重置OTP
|
|
func ResetAdminOTP() {
|
|
defaultAcount := "admin"
|
|
global.GWAF_LOCAL_DB.Where("user_name = ? ", defaultAcount).Delete(model.Otp{})
|
|
fmt.Println("Reset 2FA is successfully. ")
|
|
}
|