Introduce user level

This commit is contained in:
V2Ray committed 2015-10-31 00:38:31 +01:00
1 parent d585ec0593
commit b44098d752
6 files changed
+58 -20

No files matched your search

+7
View File
@@ -10,12 +10,14 @@ import (
type ConfigUser struct {
Id *config.ID
Email string
LevelValue config.UserLevel
}
func (u *ConfigUser) UnmarshalJSON(data []byte) error {
type rawUser struct {
IdString string `json:"id"`
EmailString string `json:"email"`
LevelInt int `json:"level"`
}
var rawUserValue rawUser
if err := json.Unmarshal(data, &rawUserValue); err != nil {
@@ -27,9 +29,14 @@ func (u *ConfigUser) UnmarshalJSON(data []byte) error {
}
u.Id = id
u.Email = rawUserValue.EmailString
u.LevelValue = config.UserLevel(rawUserValue.LevelInt)
return nil
}
func (u *ConfigUser) ID() *config.ID {
return u.Id
}
func (this *ConfigUser) Level() config.UserLevel {
return this.LevelValue
}