mirror of
https://github.com/h44z/wg-portal.git
synced 2025-08-10 07:22:24 +00:00
First user in DB is admin.
This commit is contained in:
parent
7a0a3b1e9e
commit
a9136edaa7
@ -38,6 +38,9 @@ func New(cfg *config.Config, bus evbus.MessageBus, authenticator Authenticator,
|
|||||||
startupContext, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
startupContext, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
// The first user in the DB is admin.
|
||||||
|
startupContext = context.WithValue(startupContext, domain.CtxUserInfo, domain.GetAdminInfo())
|
||||||
|
|
||||||
if err := a.createDefaultUser(startupContext); err != nil {
|
if err := a.createDefaultUser(startupContext); err != nil {
|
||||||
return nil, fmt.Errorf("failed to create default user: %w", err)
|
return nil, fmt.Errorf("failed to create default user: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -51,3 +51,9 @@ func GetUserInfo(ctx context.Context) *ContextUserInfo {
|
|||||||
|
|
||||||
return DefaultContextUserInfo()
|
return DefaultContextUserInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetAdminInfo() *ContextUserInfo {
|
||||||
|
userInfo := DefaultContextUserInfo()
|
||||||
|
userInfo.IsAdmin = true
|
||||||
|
return userInfo
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user