Pull request 2383: AGDNS-2743-aghuser
Merge in DNS/adguard-home from AGDNS-2743-aghuser to master
Squashed commit of the following:
commit e3920df62be1625a3cfcc314a4aab3d1a378ca53
Merge: 70ce647f4 106785aab
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Mon Apr 7 19:44:15 2025 +0300
Merge branch 'master' into AGDNS-2743-aghuser
commit 70ce647f47921f2bb34a561d63de2041f31e6bce
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Fri Apr 4 18:17:09 2025 +0300
aghuser: imp docs
commit 87f6984248189de4a3dc0f2a245775141ea974d0
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Wed Apr 2 19:03:03 2025 +0300
aghuser: imp code
commit 636ecae85d1fce1657b5699a29451a9079d40222
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Apr 1 17:30:54 2025 +0300
all: add tests
commit 5c842e94111123cf988332ccd1eb6754fa45585d
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Mar 27 21:44:25 2025 +0300
all: aghuser
This commit is contained in:
44
internal/aghuser/user.go
Normal file
44
internal/aghuser/user.go
Normal file
@@ -0,0 +1,44 @@
|
||||
// Package aghuser contains types and logic for dealing with AdGuard Home's web
|
||||
// users.
|
||||
package aghuser
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// UserID is the type for the unique IDs of web users.
|
||||
type UserID uuid.UUID
|
||||
|
||||
// NewUserID returns a new web user unique identifier. Any error returned is an
|
||||
// error from the cryptographic randomness reader.
|
||||
func NewUserID() (uid UserID, err error) {
|
||||
uuidv7, err := uuid.NewV7()
|
||||
|
||||
return UserID(uuidv7), err
|
||||
}
|
||||
|
||||
// MustNewUserID is a wrapper around [NewUserID] that panics if there is an
|
||||
// error. It is currently only used in tests.
|
||||
func MustNewUserID() (uid UserID) {
|
||||
uid, err := NewUserID()
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("unexpected uuidv7 error: %w", err))
|
||||
}
|
||||
|
||||
return uid
|
||||
}
|
||||
|
||||
// User represents a web user.
|
||||
type User struct {
|
||||
// ID is the unique identifier for the web user. It must not be empty.
|
||||
ID UserID
|
||||
|
||||
// Login is the login name of the web user. It must not be empty.
|
||||
Login Login
|
||||
|
||||
// Password stores the password information for the web user. It must not
|
||||
// be nil.
|
||||
Password Password
|
||||
}
|
||||
Reference in New Issue
Block a user