Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Add support for user attribute "nickname" #108

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion auth0/resource_auth0_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func newUser() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"nickname": {
Type: schema.TypeString,
Optional: true,
},
"password": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -82,6 +86,7 @@ func readUser(d *schema.ResourceData, m interface{}) error {

d.Set("user_id", u.ID)
d.Set("username", u.Username)
d.Set("nickname", u.Nickname)
d.Set("phone_number", u.PhoneNumber)
d.Set("email_verified", u.EmailVerified)
d.Set("phone_verified", u.PhoneVerified)
Expand Down Expand Up @@ -128,6 +133,7 @@ func buildUser(d *schema.ResourceData) *management.User {
ID: String(d, "user_id"),
Connection: String(d, "connection_name"),
Username: String(d, "username"),
Nickname: String(d, "nickname"),
PhoneNumber: String(d, "phone_number"),
EmailVerified: Bool(d, "email_verified"),
VerifyEmail: Bool(d, "verify_email"),
Expand All @@ -150,7 +156,7 @@ func buildUser(d *schema.ResourceData) *management.User {
}
}

if u.Username != nil || u.Password != nil || u.EmailVerified != nil || u.PhoneVerified != nil {
if u.Username != nil || u.Password != nil || u.EmailVerified != nil || u.PhoneVerified != nil || u.Nickname != nil {
// When updating email_verified, phone_verified, username or password
tkeber marked this conversation as resolved.
Show resolved Hide resolved
// we need to specify the connection property too.
//
Expand Down
8 changes: 6 additions & 2 deletions auth0/resource_auth0_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestAccUserCreateUser(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_user.user", "user_id", "12345"),
resource.TestCheckResourceAttr("auth0_user.user", "email", "test@test.com"),
resource.TestCheckResourceAttr("auth0_user.user", "nickname", "testnick"),
resource.TestCheckResourceAttr("auth0_user.user", "connection_name", "Username-Password-Authentication"),
),
},
Expand All @@ -48,13 +49,16 @@ func TestAccUserCreateUser(t *testing.T) {
}

const testAccUserCreateUser = `
provider "auth0" {}
provider "auth0" {
}

resource "auth0_user" "user" {
connection_name = "Username-Password-Authentication"
username = "test"
user_id = "12345"
email = "test@test.com"
password = "testtest$12$12"
password = "passpass$12$12"
nickname = "testnick"
user_metadata = <<EOF
{
"foo": "bar",
Expand Down
4 changes: 3 additions & 1 deletion example/user/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ provider "auth0" {}
resource "auth0_user" "user" {
connection_name = "Username-Password-Authentication"
user_id = "12345"
username = "test"
nickname = "testnick"
email = "test@test.com"
email_verified = true
password = "testtest$12$12"
password = "passpass$12$12"
}