Skip to content

Commit e112349

Browse files
authored
add auth required attributes mapping (#8263)
1 parent b751317 commit e112349

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@
641641
"frontend",
642642
"frontends",
643643
"fullheight",
644+
"fullname",
644645
"Gapi",
645646
"ge",
646647
"geo_point",

src/pages/[platform]/build-a-backend/auth/concepts/user-attributes/index.mdx

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,103 @@ export const auth = defineAuth({
6363

6464
User attributes are defined as [Cognito Standard Attributes](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#cognito-user-pools-standard-attributes). Attributes can be configured to be _required_ for user sign-up in addition to whether the values are _mutable_. When configuring your resource to allow your users to login with `email`, an email must be specified for user sign-up and cannot be changed later. However additional attributes can be configured to be optional, and mutable after sign-up.
6565

66+
```ts title="amplify/auth/resource.ts"
67+
import { defineAuth } from "@aws-amplify/backend";
68+
69+
export const auth = defineAuth({
70+
loginWith: {
71+
email: true,
72+
},
73+
userAttributes: {
74+
// Maps to Cognito standard attribute 'address'
75+
address: {
76+
mutable: true,
77+
required: true,
78+
},
79+
// Maps to Cognito standard attribute 'birthdate'
80+
birthdate: {
81+
mutable: true,
82+
required: false,
83+
},
84+
// Maps to Cognito standard attribute 'email'
85+
email: {
86+
mutable: true,
87+
required: true,
88+
},
89+
// Maps to Cognito standard attribute 'family_name'
90+
familyName: {
91+
mutable: true,
92+
required: false,
93+
},
94+
// Maps to Cognito standard attribute 'gender'
95+
gender: {
96+
mutable: true,
97+
required: false,
98+
},
99+
// Maps to Cognito standard attribute 'given_name'
100+
givenName: {
101+
mutable: true,
102+
required: false,
103+
},
104+
// Maps to Cognito standard attribute 'locale'
105+
locale: {
106+
mutable: true,
107+
required: false,
108+
},
109+
// Maps to Cognito standard attribute 'middle_name'
110+
middleName: {
111+
mutable: true,
112+
required: false,
113+
},
114+
// Maps to Cognito standard attribute 'name'
115+
fullname: {
116+
mutable: true,
117+
required: false,
118+
},
119+
// Maps to Cognito standard attribute 'nickname'
120+
nickname: {
121+
mutable: true,
122+
required: false,
123+
},
124+
// Maps to Cognito standard attribute 'phone_number'
125+
phoneNumber: {
126+
mutable: true,
127+
required: false,
128+
},
129+
// Maps to Cognito standard attribute 'picture'
130+
profilePicture: {
131+
mutable: true,
132+
required: false,
133+
},
134+
// Maps to Cognito standard attribute 'preferred_username'
135+
preferredUsername: {
136+
mutable: true,
137+
required: false,
138+
},
139+
// Maps to Cognito standard attribute 'profile'
140+
profilePage: {
141+
mutable: true,
142+
required: false,
143+
},
144+
// Maps to Cognito standard attribute 'zoneinfo'
145+
timezone: {
146+
mutable: true,
147+
required: false,
148+
},
149+
// Maps to Cognito standard attribute 'updated_at'
150+
lastUpdateTime: {
151+
mutable: true,
152+
required: false,
153+
},
154+
// Maps to Cognito standard attribute 'website'
155+
website: {
156+
mutable: true,
157+
required: false,
158+
},
159+
},
160+
});
161+
```
162+
66163
## Custom attributes
67164

68165
In addition to the provided standard attributes, you can configure [Custom Attributes](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-custom-attributes). These are attributes that are typically unique to your use case, such as a tenant ID or a user's display name. Custom attributes are identified by the `custom:` prefix:

0 commit comments

Comments
 (0)