You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
542 B
38 lines
542 B
package main
|
|
|
|
import "fmt"
|
|
|
|
type UserType int
|
|
|
|
const (
|
|
TypeAnonymous UserType = 0
|
|
TypeTelegramUser UserType = 1
|
|
TypeOidcUser UserType = 2
|
|
)
|
|
|
|
func (t UserType) String() string {
|
|
names := [...]string{
|
|
"Anonymous",
|
|
"Telegram",
|
|
"OIDC",
|
|
}
|
|
|
|
if t < TypeAnonymous || t > TypeOidcUser {
|
|
return "Unknown"
|
|
}
|
|
|
|
return names[t]
|
|
}
|
|
|
|
type WebUser struct {
|
|
Username string
|
|
Type UserType
|
|
}
|
|
|
|
func (u WebUser) String() string {
|
|
if u.Type == TypeAnonymous {
|
|
return "Anonymous"
|
|
}
|
|
|
|
return fmt.Sprintf("%s:%s", u.Type, u.Username)
|
|
}
|
|
|