all: sync with master
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