Import sources from Kontor
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package setup
|
||||
|
||||
import (
|
||||
"gitlab.ingenieurbuero-peetz.de/tpeetz/kalorienmanager.git/pkg/admin"
|
||||
"gitlab.ingenieurbuero-peetz.de/tpeetz/kalorienmanager.git/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.KalorienmanagerDb}
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user