diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f04bbcb..05d22730 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -# 0.90.65 (08-24-2020) +# 0.90.65 (09-01-2020) - Fixed issue with dashboard not logging in (notifier panic) - Modified static email templates to github.com/statping/emails - Modified Regenerate API function to keep API_SECRET env +- Added DEMO_MODE env variable, if true, 'admin' cannot be deleted # 0.90.64 (08-18-2020) - Modified max-width for container to 1012px, larger UI diff --git a/types/users/hooks.go b/types/users/hooks.go index f267c301..956d369b 100644 --- a/types/users/hooks.go +++ b/types/users/hooks.go @@ -14,6 +14,15 @@ func (u *User) Validate() error { return nil } +func (u *User) BeforeDelete() error { + if utils.Params.GetBool("DEMO_MODE") { + if u.Username == "admin" { + return errors.New("cannot delete admin in DEMO_MODE") + } + } + return nil +} + func (u *User) BeforeCreate() error { if err := u.Validate(); err != nil { return err