Create initial admin-user on startup
This commit is contained in:
parent
a3b5247da2
commit
83ca5ee435
@ -44,6 +44,17 @@ func NewServer(config *Config) (*UserServer, error) {
|
|||||||
srv.Handler = r
|
srv.Handler = r
|
||||||
srv.store = store.NewMemoryStore()
|
srv.store = store.NewMemoryStore()
|
||||||
|
|
||||||
|
// Add initial admin-user
|
||||||
|
u := users.User{
|
||||||
|
ID: uuid.Must(uuid.NewRandom()).String(),
|
||||||
|
Username: "admin",
|
||||||
|
}
|
||||||
|
password := uuid.Must(uuid.NewRandom()).String()
|
||||||
|
_ = u.SetPassword(password)
|
||||||
|
_ = srv.store.AddUser(u)
|
||||||
|
|
||||||
|
srv.Logger.Warn("Initial admin-user created.", "username", u.Username, "password", password)
|
||||||
|
|
||||||
conn, err := nats.Connect(config.NATSAddr)
|
conn, err := nats.Connect(config.NATSAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user