import sources from develop/0.1.0

This commit is contained in:
Thomas Peetz
2025-04-29 12:52:55 +02:00
parent 304005822c
commit 4c96de27db
976 changed files with 58265 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
package setup
import (
"gitlab.thpeetz.de/kontor/kontor-go/pkg/admin"
"gitlab.thpeetz.de/kontor/kontor-go/pkg/dao"
"gopkg.in/mgo.v2/bson"
)
// CheckUserList ensures that at least the admin user is available.
func CheckUserList() {
var userDao = admin.UserDAO{Db: dao.KontorDb}
users, err := userDao.FindAll()
if err == nil && len(users) == 0 {
password, _ := admin.HashPassword("admin")
id := bson.NewObjectId()
user := admin.User{ID: id, Username: "admin", Password: password, Firstname: "Administrator", IsAdmin: true}
userDao.Insert(user)
}
}