feat: cancel 2fa api

This commit is contained in:
Noah Hsu
2022-08-07 11:59:33 +08:00
parent d01958a6bf
commit 2b5da3ef34
3 changed files with 31 additions and 0 deletions

View File

@ -85,6 +85,19 @@ func UpdateUser(u *model.User) error {
return errors.WithStack(db.Save(u).Error)
}
func Cancel2FAByUser(u *model.User) error {
u.OtpSecret = ""
return errors.WithStack(UpdateUser(u))
}
func Cancel2FAById(id uint) error {
user, err := GetUserById(id)
if err != nil {
return err
}
return Cancel2FAByUser(user)
}
func GetUsers(pageIndex, pageSize int) ([]model.User, int64, error) {
userDB := db.Model(&model.User{})
var count int64