diff --git a/users/service.go b/users/service.go index c4235fcc..4f235b04 100644 --- a/users/service.go +++ b/users/service.go @@ -147,7 +147,7 @@ func (svc usersService) UserInfo(ctx context.Context, token string) (User, error func (svc usersService) UpdateUser(ctx context.Context, token string, u User) error { email, err := svc.idp.Identity(token) - if err != nil || email != u.Email { + if err != nil { return ErrUnauthorizedAccess } diff --git a/users/service_test.go b/users/service_test.go index cfdf5a06..903e6c19 100644 --- a/users/service_test.go +++ b/users/service_test.go @@ -141,12 +141,11 @@ func TestUserInfo(t *testing.T) { } } -// UpdateUser updates the user metadata - func TestUpdateUser(t *testing.T) { svc := newService() svc.Register(context.Background(), user) key, _ := svc.Login(context.Background(), user) + user.Metadata = map[string]interface{}{"role": "test"} cases := map[string]struct { @@ -154,9 +153,8 @@ func TestUpdateUser(t *testing.T) { token string err error }{ - "valid token update user": {user, key, nil}, - "invalid token's update user": {user, "", users.ErrUnauthorizedAccess}, - "non existing user update": {nonExistingUser, key, users.ErrUnauthorizedAccess}, + "update user with valid token": {user, key, nil}, + "update user with invalid token": {user, "non-existent", users.ErrUnauthorizedAccess}, } for desc, tc := range cases {