1
0

Hide a users email everywhere (#69)

This commit is contained in:
konrad
2019-04-01 18:19:55 +00:00
committed by Gitea
parent ac5446e4f5
commit 19faee0102
9 changed files with 32 additions and 42 deletions

View File

@ -49,7 +49,6 @@ func TestLabelTask_ReadAll(t *testing.T) {
ID: 2,
Username: "user2",
Password: "1234",
Email: "user2@example.com",
},
},
},

View File

@ -46,7 +46,6 @@ func TestLabel_ReadAll(t *testing.T) {
ID: 1,
Username: "user1",
Password: "1234",
Email: "user1@example.com",
}
tests := []struct {
name string
@ -87,7 +86,6 @@ func TestLabel_ReadAll(t *testing.T) {
ID: 2,
Username: "user2",
Password: "1234",
Email: "user2@example.com",
},
},
},
@ -141,7 +139,6 @@ func TestLabel_ReadOne(t *testing.T) {
ID: 1,
Username: "user1",
Password: "1234",
Email: "user1@example.com",
}
tests := []struct {
name string
@ -196,7 +193,6 @@ func TestLabel_ReadOne(t *testing.T) {
ID: 2,
Username: "user2",
Password: "1234",
Email: "user2@example.com",
},
},
auth: &User{ID: 1},

View File

@ -160,7 +160,6 @@ func TestListUser_ReadAll(t *testing.T) {
ID: 1,
Username: "user1",
Password: "1234",
Email: "user1@example.com",
},
Right: RightRead,
},
@ -169,7 +168,6 @@ func TestListUser_ReadAll(t *testing.T) {
ID: 2,
Username: "user2",
Password: "1234",
Email: "user2@example.com",
},
Right: RightRead,
},

View File

@ -161,7 +161,6 @@ func TestNamespaceUser_ReadAll(t *testing.T) {
ID: 1,
Username: "user1",
Password: "1234",
Email: "user1@example.com",
},
Right: RightRead,
},
@ -170,7 +169,6 @@ func TestNamespaceUser_ReadAll(t *testing.T) {
ID: 2,
Username: "user2",
Password: "1234",
Email: "user2@example.com",
},
Right: RightRead,
},

View File

@ -44,7 +44,7 @@ type User struct {
Username string `xorm:"varchar(250) not null unique" json:"username" valid:"length(3|250)" minLength:"3" maxLength:"250"`
Password string `xorm:"varchar(250) not null" json:"-"`
// The user's email address.
Email string `xorm:"varchar(250) null" json:"email" valid:"email,length(0|250)" maxLength:"250"`
Email string `xorm:"varchar(250) null" json:"email,omitonempty" valid:"email,length(0|250)" maxLength:"250"`
IsActive bool `xorm:"null" json:"-"`
PasswordResetToken string `xorm:"varchar(450) null" json:"-"`
@ -58,6 +58,11 @@ type User struct {
web.Auth `xorm:"-" json:"-"`
}
// AfterLoad is used to delete all emails to not have them leaked to the user
func (u *User) AfterLoad() {
u.Email = ""
}
// AuthDummy implements the auth of the crud handler
func (User) AuthDummy() {}