forge
Explore
Log in

Don't you dare go Hollow

Add gender, address, and emergency contact to the user row

Browse files at this commit

f151345d92f9caf95fb6eb05049cf31dbf89dc9fAhmet Kaan GümüşParent: 5d43523
  • feat
    • add gender, address, and emergency contact to the user row
Show full message
✨ feat(profile): add gender, address, and emergency contact to the user row
Local-Gate: 1f2b0abcf3798a63b2c5365e0d15c9f708f45833 (1523 passed, 430s)
.sqlx/query-e30a05b019f2834851c819abde37d928f6a02f051e99bc877168f48d142bff8b.json → .sqlx/query-11efb8f095f9c3a25f15e81c63f7c8ce6060d4a07381e18af874156b5a9355a2.jsonrenamed+59 -11
@@ -1,6 +1,6 @@
11 {
22 "db_name": "PostgreSQL",
3- "query": "INSERT INTO app_user (id, username, person, role, student_number, created_at)\n VALUES ($1, $2, $3, $4, $5, $6)\n RETURNING id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size",
3+ "query": "INSERT INTO app_user (id, username, person, role, student_number, created_at)\n VALUES ($1, $2, $3, $4, $5, $6)\n RETURNING id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size",
44 "describe": {
55 "columns": [
66 {
@@ -104,6 +104,50 @@
104104 },
105105 {
106106 "ordinal": 9,
107+ "name": "gender: Gender",
108+ "type_info": "Text",
109+ "origin": {
110+ "Table": {
111+ "table": "app_user",
112+ "name": "gender"
113+ }
114+ }
115+ },
116+ {
117+ "ordinal": 10,
118+ "name": "address: Address",
119+ "type_info": "Text",
120+ "origin": {
121+ "Table": {
122+ "table": "app_user",
123+ "name": "address"
124+ }
125+ }
126+ },
127+ {
128+ "ordinal": 11,
129+ "name": "emergency_contact_name: PersonName",
130+ "type_info": "Text",
131+ "origin": {
132+ "Table": {
133+ "table": "app_user",
134+ "name": "emergency_contact_name"
135+ }
136+ }
137+ },
138+ {
139+ "ordinal": 12,
140+ "name": "emergency_contact_phone: Phone",
141+ "type_info": "Text",
142+ "origin": {
143+ "Table": {
144+ "table": "app_user",
145+ "name": "emergency_contact_phone"
146+ }
147+ }
148+ },
149+ {
150+ "ordinal": 13,
107151 "name": "theme: Theme",
108152 "type_info": "Text",
109153 "origin": {
@@ -114,7 +158,7 @@
114158 }
115159 },
116160 {
117- "ordinal": 10,
161+ "ordinal": 14,
118162 "name": "language: Language",
119163 "type_info": "Text",
120164 "origin": {
@@ -125,7 +169,7 @@
125169 }
126170 },
127171 {
128- "ordinal": 11,
172+ "ordinal": 15,
129173 "name": "palette_color: PaletteColor",
130174 "type_info": "Text",
131175 "origin": {
@@ -136,7 +180,7 @@
136180 }
137181 },
138182 {
139- "ordinal": 12,
183+ "ordinal": 16,
140184 "name": "display_name: DisplayName",
141185 "type_info": "Text",
142186 "origin": {
@@ -147,7 +191,7 @@
147191 }
148192 },
149193 {
150- "ordinal": 13,
194+ "ordinal": 17,
151195 "name": "bio: Bio",
152196 "type_info": "Text",
153197 "origin": {
@@ -158,7 +202,7 @@
158202 }
159203 },
160204 {
161- "ordinal": 14,
205+ "ordinal": 18,
162206 "name": "avatar_file",
163207 "type_info": "Text",
164208 "origin": {
@@ -169,7 +213,7 @@
169213 }
170214 },
171215 {
172- "ordinal": 15,
216+ "ordinal": 19,
173217 "name": "avatar_content_type: FileContentType",
174218 "type_info": "Text",
175219 "origin": {
@@ -180,7 +224,7 @@
180224 }
181225 },
182226 {
183- "ordinal": 16,
227+ "ordinal": 20,
184228 "name": "branch",
185229 "type_info": "Text",
186230 "origin": {
@@ -191,7 +235,7 @@
191235 }
192236 },
193237 {
194- "ordinal": 17,
238+ "ordinal": 21,
195239 "name": "student_number: StudentNumber",
196240 "type_info": "Text",
197241 "origin": {
@@ -202,7 +246,7 @@
202246 }
203247 },
204248 {
205- "ordinal": 18,
249+ "ordinal": 22,
206250 "name": "avatar_size",
207251 "type_info": "Int8",
208252 "origin": {
@@ -242,8 +286,12 @@
242286 true,
243287 true,
244288 true,
289+ true,
290+ true,
291+ true,
292+ true,
245293 true
246294 ]
247295 },
248- "hash": "e30a05b019f2834851c819abde37d928f6a02f051e99bc877168f48d142bff8b"
296+ "hash": "11efb8f095f9c3a25f15e81c63f7c8ce6060d4a07381e18af874156b5a9355a2"
249297 }
.sqlx/query-ac0befbd1b4398d79d2bbe2d8923bde69dfbe93bbb60dadc632ce93bbe18f8a6.json → .sqlx/query-285553fed5434ba6d2dc0b5f8cfca643533fc704888da822bda102b292a59a58.jsonrenamed+59 -11
@@ -1,6 +1,6 @@
11 {
22 "db_name": "PostgreSQL",
3- "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = $1",
3+ "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = $1",
44 "describe": {
55 "columns": [
66 {
@@ -104,6 +104,50 @@
104104 },
105105 {
106106 "ordinal": 9,
107+ "name": "gender: Gender",
108+ "type_info": "Text",
109+ "origin": {
110+ "Table": {
111+ "table": "app_user",
112+ "name": "gender"
113+ }
114+ }
115+ },
116+ {
117+ "ordinal": 10,
118+ "name": "address: Address",
119+ "type_info": "Text",
120+ "origin": {
121+ "Table": {
122+ "table": "app_user",
123+ "name": "address"
124+ }
125+ }
126+ },
127+ {
128+ "ordinal": 11,
129+ "name": "emergency_contact_name: PersonName",
130+ "type_info": "Text",
131+ "origin": {
132+ "Table": {
133+ "table": "app_user",
134+ "name": "emergency_contact_name"
135+ }
136+ }
137+ },
138+ {
139+ "ordinal": 12,
140+ "name": "emergency_contact_phone: Phone",
141+ "type_info": "Text",
142+ "origin": {
143+ "Table": {
144+ "table": "app_user",
145+ "name": "emergency_contact_phone"
146+ }
147+ }
148+ },
149+ {
150+ "ordinal": 13,
107151 "name": "theme: Theme",
108152 "type_info": "Text",
109153 "origin": {
@@ -114,7 +158,7 @@
114158 }
115159 },
116160 {
117- "ordinal": 10,
161+ "ordinal": 14,
118162 "name": "language: Language",
119163 "type_info": "Text",
120164 "origin": {
@@ -125,7 +169,7 @@
125169 }
126170 },
127171 {
128- "ordinal": 11,
172+ "ordinal": 15,
129173 "name": "palette_color: PaletteColor",
130174 "type_info": "Text",
131175 "origin": {
@@ -136,7 +180,7 @@
136180 }
137181 },
138182 {
139- "ordinal": 12,
183+ "ordinal": 16,
140184 "name": "display_name: DisplayName",
141185 "type_info": "Text",
142186 "origin": {
@@ -147,7 +191,7 @@
147191 }
148192 },
149193 {
150- "ordinal": 13,
194+ "ordinal": 17,
151195 "name": "bio: Bio",
152196 "type_info": "Text",
153197 "origin": {
@@ -158,7 +202,7 @@
158202 }
159203 },
160204 {
161- "ordinal": 14,
205+ "ordinal": 18,
162206 "name": "avatar_file",
163207 "type_info": "Text",
164208 "origin": {
@@ -169,7 +213,7 @@
169213 }
170214 },
171215 {
172- "ordinal": 15,
216+ "ordinal": 19,
173217 "name": "avatar_content_type: FileContentType",
174218 "type_info": "Text",
175219 "origin": {
@@ -180,7 +224,7 @@
180224 }
181225 },
182226 {
183- "ordinal": 16,
227+ "ordinal": 20,
184228 "name": "branch",
185229 "type_info": "Text",
186230 "origin": {
@@ -191,7 +235,7 @@
191235 }
192236 },
193237 {
194- "ordinal": 17,
238+ "ordinal": 21,
195239 "name": "student_number: StudentNumber",
196240 "type_info": "Text",
197241 "origin": {
@@ -202,7 +246,7 @@
202246 }
203247 },
204248 {
205- "ordinal": 18,
249+ "ordinal": 22,
206250 "name": "avatar_size",
207251 "type_info": "Int8",
208252 "origin": {
@@ -237,8 +281,12 @@
237281 true,
238282 true,
239283 true,
284+ true,
285+ true,
286+ true,
287+ true,
240288 true
241289 ]
242290 },
243- "hash": "ac0befbd1b4398d79d2bbe2d8923bde69dfbe93bbb60dadc632ce93bbe18f8a6"
291+ "hash": "285553fed5434ba6d2dc0b5f8cfca643533fc704888da822bda102b292a59a58"
244292 }
.sqlx/query-0887ff018a2ecdc9bf29472dd59b5e7f76610c2a39de92e7b30ad8be5a5966f8.json → .sqlx/query-2e30b1574b30eeea4de6f677fffa01a753f85e8940e85c30a65367bab6a85472.jsonrenamed+59 -11
@@ -1,6 +1,6 @@
11 {
22 "db_name": "PostgreSQL",
3- "query": "UPDATE app_user\n SET role = $2,\n student_number = CASE WHEN $2 = 'student' THEN student_number ELSE NULL END\n WHERE id = $1\n AND NOT (role = 'admin'\n AND $2 <> 'admin'\n AND (SELECT count(*) FROM app_user\n WHERE role = 'admin' AND id <> $1) = 0)\n RETURNING id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size",
3+ "query": "UPDATE app_user\n SET role = $2,\n student_number = CASE WHEN $2 = 'student' THEN student_number ELSE NULL END\n WHERE id = $1\n AND NOT (role = 'admin'\n AND $2 <> 'admin'\n AND (SELECT count(*) FROM app_user\n WHERE role = 'admin' AND id <> $1) = 0)\n RETURNING id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size",
44 "describe": {
55 "columns": [
66 {
@@ -104,6 +104,50 @@
104104 },
105105 {
106106 "ordinal": 9,
107+ "name": "gender: Gender",
108+ "type_info": "Text",
109+ "origin": {
110+ "Table": {
111+ "table": "app_user",
112+ "name": "gender"
113+ }
114+ }
115+ },
116+ {
117+ "ordinal": 10,
118+ "name": "address: Address",
119+ "type_info": "Text",
120+ "origin": {
121+ "Table": {
122+ "table": "app_user",
123+ "name": "address"
124+ }
125+ }
126+ },
127+ {
128+ "ordinal": 11,
129+ "name": "emergency_contact_name: PersonName",
130+ "type_info": "Text",
131+ "origin": {
132+ "Table": {
133+ "table": "app_user",
134+ "name": "emergency_contact_name"
135+ }
136+ }
137+ },
138+ {
139+ "ordinal": 12,
140+ "name": "emergency_contact_phone: Phone",
141+ "type_info": "Text",
142+ "origin": {
143+ "Table": {
144+ "table": "app_user",
145+ "name": "emergency_contact_phone"
146+ }
147+ }
148+ },
149+ {
150+ "ordinal": 13,
107151 "name": "theme: Theme",
108152 "type_info": "Text",
109153 "origin": {
@@ -114,7 +158,7 @@
114158 }
115159 },
116160 {
117- "ordinal": 10,
161+ "ordinal": 14,
118162 "name": "language: Language",
119163 "type_info": "Text",
120164 "origin": {
@@ -125,7 +169,7 @@
125169 }
126170 },
127171 {
128- "ordinal": 11,
172+ "ordinal": 15,
129173 "name": "palette_color: PaletteColor",
130174 "type_info": "Text",
131175 "origin": {
@@ -136,7 +180,7 @@
136180 }
137181 },
138182 {
139- "ordinal": 12,
183+ "ordinal": 16,
140184 "name": "display_name: DisplayName",
141185 "type_info": "Text",
142186 "origin": {
@@ -147,7 +191,7 @@
147191 }
148192 },
149193 {
150- "ordinal": 13,
194+ "ordinal": 17,
151195 "name": "bio: Bio",
152196 "type_info": "Text",
153197 "origin": {
@@ -158,7 +202,7 @@
158202 }
159203 },
160204 {
161- "ordinal": 14,
205+ "ordinal": 18,
162206 "name": "avatar_file",
163207 "type_info": "Text",
164208 "origin": {
@@ -169,7 +213,7 @@
169213 }
170214 },
171215 {
172- "ordinal": 15,
216+ "ordinal": 19,
173217 "name": "avatar_content_type: FileContentType",
174218 "type_info": "Text",
175219 "origin": {
@@ -180,7 +224,7 @@
180224 }
181225 },
182226 {
183- "ordinal": 16,
227+ "ordinal": 20,
184228 "name": "branch",
185229 "type_info": "Text",
186230 "origin": {
@@ -191,7 +235,7 @@
191235 }
192236 },
193237 {
194- "ordinal": 17,
238+ "ordinal": 21,
195239 "name": "student_number: StudentNumber",
196240 "type_info": "Text",
197241 "origin": {
@@ -202,7 +246,7 @@
202246 }
203247 },
204248 {
205- "ordinal": 18,
249+ "ordinal": 22,
206250 "name": "avatar_size",
207251 "type_info": "Int8",
208252 "origin": {
@@ -238,8 +282,12 @@
238282 true,
239283 true,
240284 true,
285+ true,
286+ true,
287+ true,
288+ true,
241289 true
242290 ]
243291 },
244- "hash": "0887ff018a2ecdc9bf29472dd59b5e7f76610c2a39de92e7b30ad8be5a5966f8"
292+ "hash": "2e30b1574b30eeea4de6f677fffa01a753f85e8940e85c30a65367bab6a85472"
245293 }
.sqlx/query-09f4fca0c1cf695324fd71baec63fd30baa3cfff04429798e9e8784ffb611ede.json → .sqlx/query-3570903f9c3efa997ab946792400987bf2ba4f6c0a0121812e08abe12d495f0d.jsonrenamed+59 -11
@@ -1,6 +1,6 @@
11 {
22 "db_name": "PostgreSQL",
3- "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = ANY($1)",
3+ "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = ANY($1)",
44 "describe": {
55 "columns": [
66 {
@@ -104,6 +104,50 @@
104104 },
105105 {
106106 "ordinal": 9,
107+ "name": "gender: Gender",
108+ "type_info": "Text",
109+ "origin": {
110+ "Table": {
111+ "table": "app_user",
112+ "name": "gender"
113+ }
114+ }
115+ },
116+ {
117+ "ordinal": 10,
118+ "name": "address: Address",
119+ "type_info": "Text",
120+ "origin": {
121+ "Table": {
122+ "table": "app_user",
123+ "name": "address"
124+ }
125+ }
126+ },
127+ {
128+ "ordinal": 11,
129+ "name": "emergency_contact_name: PersonName",
130+ "type_info": "Text",
131+ "origin": {
132+ "Table": {
133+ "table": "app_user",
134+ "name": "emergency_contact_name"
135+ }
136+ }
137+ },
138+ {
139+ "ordinal": 12,
140+ "name": "emergency_contact_phone: Phone",
141+ "type_info": "Text",
142+ "origin": {
143+ "Table": {
144+ "table": "app_user",
145+ "name": "emergency_contact_phone"
146+ }
147+ }
148+ },
149+ {
150+ "ordinal": 13,
107151 "name": "theme: Theme",
108152 "type_info": "Text",
109153 "origin": {
@@ -114,7 +158,7 @@
114158 }
115159 },
116160 {
117- "ordinal": 10,
161+ "ordinal": 14,
118162 "name": "language: Language",
119163 "type_info": "Text",
120164 "origin": {
@@ -125,7 +169,7 @@
125169 }
126170 },
127171 {
128- "ordinal": 11,
172+ "ordinal": 15,
129173 "name": "palette_color: PaletteColor",
130174 "type_info": "Text",
131175 "origin": {
@@ -136,7 +180,7 @@
136180 }
137181 },
138182 {
139- "ordinal": 12,
183+ "ordinal": 16,
140184 "name": "display_name: DisplayName",
141185 "type_info": "Text",
142186 "origin": {
@@ -147,7 +191,7 @@
147191 }
148192 },
149193 {
150- "ordinal": 13,
194+ "ordinal": 17,
151195 "name": "bio: Bio",
152196 "type_info": "Text",
153197 "origin": {
@@ -158,7 +202,7 @@
158202 }
159203 },
160204 {
161- "ordinal": 14,
205+ "ordinal": 18,
162206 "name": "avatar_file",
163207 "type_info": "Text",
164208 "origin": {
@@ -169,7 +213,7 @@
169213 }
170214 },
171215 {
172- "ordinal": 15,
216+ "ordinal": 19,
173217 "name": "avatar_content_type: FileContentType",
174218 "type_info": "Text",
175219 "origin": {
@@ -180,7 +224,7 @@
180224 }
181225 },
182226 {
183- "ordinal": 16,
227+ "ordinal": 20,
184228 "name": "branch",
185229 "type_info": "Text",
186230 "origin": {
@@ -191,7 +235,7 @@
191235 }
192236 },
193237 {
194- "ordinal": 17,
238+ "ordinal": 21,
195239 "name": "student_number: StudentNumber",
196240 "type_info": "Text",
197241 "origin": {
@@ -202,7 +246,7 @@
202246 }
203247 },
204248 {
205- "ordinal": 18,
249+ "ordinal": 22,
206250 "name": "avatar_size",
207251 "type_info": "Int8",
208252 "origin": {
@@ -237,8 +281,12 @@
237281 true,
238282 true,
239283 true,
284+ true,
285+ true,
286+ true,
287+ true,
240288 true
241289 ]
242290 },
243- "hash": "09f4fca0c1cf695324fd71baec63fd30baa3cfff04429798e9e8784ffb611ede"
291+ "hash": "3570903f9c3efa997ab946792400987bf2ba4f6c0a0121812e08abe12d495f0d"
244292 }
.sqlx/query-c8eeec6b17943f913ed919e8663e44fc9d0e85ac9eaa6a7f2c9b012237381d5c.json → .sqlx/query-56cb33247c6d8b90a8f8adbf74020e68e743aafd2373a5ba08d2340edfea70f6.jsonrenamed+59 -11
@@ -1,6 +1,6 @@
11 {
22 "db_name": "PostgreSQL",
3- "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE role = $1 ORDER BY id DESC",
3+ "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE role = $1 ORDER BY id DESC",
44 "describe": {
55 "columns": [
66 {
@@ -104,6 +104,50 @@
104104 },
105105 {
106106 "ordinal": 9,
107+ "name": "gender: Gender",
108+ "type_info": "Text",
109+ "origin": {
110+ "Table": {
111+ "table": "app_user",
112+ "name": "gender"
113+ }
114+ }
115+ },
116+ {
117+ "ordinal": 10,
118+ "name": "address: Address",
119+ "type_info": "Text",
120+ "origin": {
121+ "Table": {
122+ "table": "app_user",
123+ "name": "address"
124+ }
125+ }
126+ },
127+ {
128+ "ordinal": 11,
129+ "name": "emergency_contact_name: PersonName",
130+ "type_info": "Text",
131+ "origin": {
132+ "Table": {
133+ "table": "app_user",
134+ "name": "emergency_contact_name"
135+ }
136+ }
137+ },
138+ {
139+ "ordinal": 12,
140+ "name": "emergency_contact_phone: Phone",
141+ "type_info": "Text",
142+ "origin": {
143+ "Table": {
144+ "table": "app_user",
145+ "name": "emergency_contact_phone"
146+ }
147+ }
148+ },
149+ {
150+ "ordinal": 13,
107151 "name": "theme: Theme",
108152 "type_info": "Text",
109153 "origin": {
@@ -114,7 +158,7 @@
114158 }
115159 },
116160 {
117- "ordinal": 10,
161+ "ordinal": 14,
118162 "name": "language: Language",
119163 "type_info": "Text",
120164 "origin": {
@@ -125,7 +169,7 @@
125169 }
126170 },
127171 {
128- "ordinal": 11,
172+ "ordinal": 15,
129173 "name": "palette_color: PaletteColor",
130174 "type_info": "Text",
131175 "origin": {
@@ -136,7 +180,7 @@
136180 }
137181 },
138182 {
139- "ordinal": 12,
183+ "ordinal": 16,
140184 "name": "display_name: DisplayName",
141185 "type_info": "Text",
142186 "origin": {
@@ -147,7 +191,7 @@
147191 }
148192 },
149193 {
150- "ordinal": 13,
194+ "ordinal": 17,
151195 "name": "bio: Bio",
152196 "type_info": "Text",
153197 "origin": {
@@ -158,7 +202,7 @@
158202 }
159203 },
160204 {
161- "ordinal": 14,
205+ "ordinal": 18,
162206 "name": "avatar_file",
163207 "type_info": "Text",
164208 "origin": {
@@ -169,7 +213,7 @@
169213 }
170214 },
171215 {
172- "ordinal": 15,
216+ "ordinal": 19,
173217 "name": "avatar_content_type: FileContentType",
174218 "type_info": "Text",
175219 "origin": {
@@ -180,7 +224,7 @@
180224 }
181225 },
182226 {
183- "ordinal": 16,
227+ "ordinal": 20,
184228 "name": "branch",
185229 "type_info": "Text",
186230 "origin": {
@@ -191,7 +235,7 @@
191235 }
192236 },
193237 {
194- "ordinal": 17,
238+ "ordinal": 21,
195239 "name": "student_number: StudentNumber",
196240 "type_info": "Text",
197241 "origin": {
@@ -202,7 +246,7 @@
202246 }
203247 },
204248 {
205- "ordinal": 18,
249+ "ordinal": 22,
206250 "name": "avatar_size",
207251 "type_info": "Int8",
208252 "origin": {
@@ -237,8 +281,12 @@
237281 true,
238282 true,
239283 true,
284+ true,
285+ true,
286+ true,
287+ true,
240288 true
241289 ]
242290 },
243- "hash": "c8eeec6b17943f913ed919e8663e44fc9d0e85ac9eaa6a7f2c9b012237381d5c"
291+ "hash": "56cb33247c6d8b90a8f8adbf74020e68e743aafd2373a5ba08d2340edfea70f6"
244292 }
.sqlx/query-fb4bc5f405406b6b5f6a41705b65ceb78cd496905d3da3669ab659e57b0ed7fc.json → .sqlx/query-584815529fd2220312415393ca0fe9036201139d948c2fdcd17da489b473161c.jsonrenamed+59 -11
@@ -1,6 +1,6 @@
11 {
22 "db_name": "PostgreSQL",
3- "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE username = $1",
3+ "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE username = $1",
44 "describe": {
55 "columns": [
66 {
@@ -104,6 +104,50 @@
104104 },
105105 {
106106 "ordinal": 9,
107+ "name": "gender: Gender",
108+ "type_info": "Text",
109+ "origin": {
110+ "Table": {
111+ "table": "app_user",
112+ "name": "gender"
113+ }
114+ }
115+ },
116+ {
117+ "ordinal": 10,
118+ "name": "address: Address",
119+ "type_info": "Text",
120+ "origin": {
121+ "Table": {
122+ "table": "app_user",
123+ "name": "address"
124+ }
125+ }
126+ },
127+ {
128+ "ordinal": 11,
129+ "name": "emergency_contact_name: PersonName",
130+ "type_info": "Text",
131+ "origin": {
132+ "Table": {
133+ "table": "app_user",
134+ "name": "emergency_contact_name"
135+ }
136+ }
137+ },
138+ {
139+ "ordinal": 12,
140+ "name": "emergency_contact_phone: Phone",
141+ "type_info": "Text",
142+ "origin": {
143+ "Table": {
144+ "table": "app_user",
145+ "name": "emergency_contact_phone"
146+ }
147+ }
148+ },
149+ {
150+ "ordinal": 13,
107151 "name": "theme: Theme",
108152 "type_info": "Text",
109153 "origin": {
@@ -114,7 +158,7 @@
114158 }
115159 },
116160 {
117- "ordinal": 10,
161+ "ordinal": 14,
118162 "name": "language: Language",
119163 "type_info": "Text",
120164 "origin": {
@@ -125,7 +169,7 @@
125169 }
126170 },
127171 {
128- "ordinal": 11,
172+ "ordinal": 15,
129173 "name": "palette_color: PaletteColor",
130174 "type_info": "Text",
131175 "origin": {
@@ -136,7 +180,7 @@
136180 }
137181 },
138182 {
139- "ordinal": 12,
183+ "ordinal": 16,
140184 "name": "display_name: DisplayName",
141185 "type_info": "Text",
142186 "origin": {
@@ -147,7 +191,7 @@
147191 }
148192 },
149193 {
150- "ordinal": 13,
194+ "ordinal": 17,
151195 "name": "bio: Bio",
152196 "type_info": "Text",
153197 "origin": {
@@ -158,7 +202,7 @@
158202 }
159203 },
160204 {
161- "ordinal": 14,
205+ "ordinal": 18,
162206 "name": "avatar_file",
163207 "type_info": "Text",
164208 "origin": {
@@ -169,7 +213,7 @@
169213 }
170214 },
171215 {
172- "ordinal": 15,
216+ "ordinal": 19,
173217 "name": "avatar_content_type: FileContentType",
174218 "type_info": "Text",
175219 "origin": {
@@ -180,7 +224,7 @@
180224 }
181225 },
182226 {
183- "ordinal": 16,
227+ "ordinal": 20,
184228 "name": "branch",
185229 "type_info": "Text",
186230 "origin": {
@@ -191,7 +235,7 @@
191235 }
192236 },
193237 {
194- "ordinal": 17,
238+ "ordinal": 21,
195239 "name": "student_number: StudentNumber",
196240 "type_info": "Text",
197241 "origin": {
@@ -202,7 +246,7 @@
202246 }
203247 },
204248 {
205- "ordinal": 18,
249+ "ordinal": 22,
206250 "name": "avatar_size",
207251 "type_info": "Int8",
208252 "origin": {
@@ -237,8 +281,12 @@
237281 true,
238282 true,
239283 true,
284+ true,
285+ true,
286+ true,
287+ true,
240288 true
241289 ]
242290 },
243- "hash": "fb4bc5f405406b6b5f6a41705b65ceb78cd496905d3da3669ab659e57b0ed7fc"
291+ "hash": "584815529fd2220312415393ca0fe9036201139d948c2fdcd17da489b473161c"
244292 }
.sqlx/query-7496e13f38da77b1fc311a687f1996651f4d8ce46c0ee401f63d2a5f80334ab2.json → .sqlx/query-7d46215022acf66ec30b62b6022443ef169dd0b12bb3e3824cf706b6245045fc.jsonrenamed+59 -11
@@ -1,6 +1,6 @@
11 {
22 "db_name": "PostgreSQL",
3- "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = $1 FOR UPDATE",
3+ "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = $1 FOR UPDATE",
44 "describe": {
55 "columns": [
66 {
@@ -104,6 +104,50 @@
104104 },
105105 {
106106 "ordinal": 9,
107+ "name": "gender: Gender",
108+ "type_info": "Text",
109+ "origin": {
110+ "Table": {
111+ "table": "app_user",
112+ "name": "gender"
113+ }
114+ }
115+ },
116+ {
117+ "ordinal": 10,
118+ "name": "address: Address",
119+ "type_info": "Text",
120+ "origin": {
121+ "Table": {
122+ "table": "app_user",
123+ "name": "address"
124+ }
125+ }
126+ },
127+ {
128+ "ordinal": 11,
129+ "name": "emergency_contact_name: PersonName",
130+ "type_info": "Text",
131+ "origin": {
132+ "Table": {
133+ "table": "app_user",
134+ "name": "emergency_contact_name"
135+ }
136+ }
137+ },
138+ {
139+ "ordinal": 12,
140+ "name": "emergency_contact_phone: Phone",
141+ "type_info": "Text",
142+ "origin": {
143+ "Table": {
144+ "table": "app_user",
145+ "name": "emergency_contact_phone"
146+ }
147+ }
148+ },
149+ {
150+ "ordinal": 13,
107151 "name": "theme: Theme",
108152 "type_info": "Text",
109153 "origin": {
@@ -114,7 +158,7 @@
114158 }
115159 },
116160 {
117- "ordinal": 10,
161+ "ordinal": 14,
118162 "name": "language: Language",
119163 "type_info": "Text",
120164 "origin": {
@@ -125,7 +169,7 @@
125169 }
126170 },
127171 {
128- "ordinal": 11,
172+ "ordinal": 15,
129173 "name": "palette_color: PaletteColor",
130174 "type_info": "Text",
131175 "origin": {
@@ -136,7 +180,7 @@
136180 }
137181 },
138182 {
139- "ordinal": 12,
183+ "ordinal": 16,
140184 "name": "display_name: DisplayName",
141185 "type_info": "Text",
142186 "origin": {
@@ -147,7 +191,7 @@
147191 }
148192 },
149193 {
150- "ordinal": 13,
194+ "ordinal": 17,
151195 "name": "bio: Bio",
152196 "type_info": "Text",
153197 "origin": {
@@ -158,7 +202,7 @@
158202 }
159203 },
160204 {
161- "ordinal": 14,
205+ "ordinal": 18,
162206 "name": "avatar_file",
163207 "type_info": "Text",
164208 "origin": {
@@ -169,7 +213,7 @@
169213 }
170214 },
171215 {
172- "ordinal": 15,
216+ "ordinal": 19,
173217 "name": "avatar_content_type: FileContentType",
174218 "type_info": "Text",
175219 "origin": {
@@ -180,7 +224,7 @@
180224 }
181225 },
182226 {
183- "ordinal": 16,
227+ "ordinal": 20,
184228 "name": "branch",
185229 "type_info": "Text",
186230 "origin": {
@@ -191,7 +235,7 @@
191235 }
192236 },
193237 {
194- "ordinal": 17,
238+ "ordinal": 21,
195239 "name": "student_number: StudentNumber",
196240 "type_info": "Text",
197241 "origin": {
@@ -202,7 +246,7 @@
202246 }
203247 },
204248 {
205- "ordinal": 18,
249+ "ordinal": 22,
206250 "name": "avatar_size",
207251 "type_info": "Int8",
208252 "origin": {
@@ -237,8 +281,12 @@
237281 true,
238282 true,
239283 true,
284+ true,
285+ true,
286+ true,
287+ true,
240288 true
241289 ]
242290 },
243- "hash": "7496e13f38da77b1fc311a687f1996651f4d8ce46c0ee401f63d2a5f80334ab2"
291+ "hash": "7d46215022acf66ec30b62b6022443ef169dd0b12bb3e3824cf706b6245045fc"
244292 }
README.mdmodified+14 -5
@@ -645,12 +645,13 @@ response in the same commit.
645645 "reserved_usernames": ["admin", "…"],
646646 "min_password_len": 6, "max_password_len": 128,
647647 "max_name_len": 100, "max_display_name_len": 50,
648- "max_bio_len": 500,
648+ "max_bio_len": 500, "max_address_len": 500,
649649 "max_profile_courses": 20, "max_profile_classes": 5,
650650 "max_email_len": 254,
651651 "min_phone_digits": 7, "max_phone_digits": 15,
652652 "roles": ["parent", "student", "teacher", "manager", "admin"],
653653 "themes": ["light", "dark"], "languages": ["tr", "en"],
654+ "genders": ["female", "male", "other", "undisclosed"],
654655 "palette_color_pattern": "^#[0-9a-fA-F]{6}$", "palette_color_len": 7,
655656 "session_duration_days": 7 },
656657 "badges": { "catalog": [ { "id": "homework_submitted_10",
@@ -722,7 +723,7 @@ drift from it**, which is enforced rather than asked for:
722723 and fails unless each one is either referenced by `src/web/limits.rs` or
723724 listed as a deliberate exclusion *with a reason*. A new constant breaks the
724725 suite until someone decides, consciously, whether clients need it.
725-- `tests/spec_bounds.rs` builds the OpenAPI document, reads all 218 published
726+- `tests/spec_bounds.rs` builds the OpenAPI document, reads all 220 published
726727 bounds back out of the emitted JSON, and asserts each equals its constant.
727728 This exists because utoipa's `#[schema(max_length = …)]` accepts a **literal
728729 only** — a `const` there does not compile — so the annotations are
@@ -1601,7 +1602,12 @@ is independent: omitted (or `null`) keeps the current value, an empty string
16011602 `""` clears it, anything else is validated — email must look like
16021603 `name@example.com`, phone is 7–15 digits with an optional `+` and cosmetic
16031604 separators, `birth_date` is a real `YYYY-MM-DD` calendar date not in the
1604-future. Names allow unicode; usernames are strict: lowercase letters and
1605+future. The profile extras ride the same patch with the same semantics:
1606+`gender` is one of the four fixed words `female`/`male`/`other`/`undisclosed`
1607+(a closed vocabulary — anything else is a `400`), `address` is free text up to
1608+`max_address_len` (500), and `emergency_contact_name` /
1609+`emergency_contact_phone` follow the `name` and `phone` rules respectively.
1610+Names allow unicode; usernames are strict: lowercase letters and
16051611 digits plus non-consecutive interior `.`, `_`, `-` separators, starting and
16061612 ending with a letter or digit (3–32 chars). Staff-looking names (`admin`,
16071613 `administrator`, `root`, `support`, `system`, `moderator`, `staff`) are
@@ -1650,8 +1656,11 @@ the school. `GET /users/me/profile` is the caller's own copy of it,
16501656 ```
16511657
16521658 **Contact fields are absent by design.** `email`, `phone` and `birth_date` are
1653-not on this document at any role — they keep exactly the gate they have today
1654-(`GET /auth/me` for oneself, `GET /users/{id}` for an admin). A school-wide
1659+not on this document at any role, and neither are the profile extras that say
1660+where a person lives or who to call for them (`gender`, `address`,
1661+`emergency_contact_name`, `emergency_contact_phone`) — they keep exactly the
1662+gate the other contact fields have (`GET /auth/me` for oneself,
1663+`GET /users/{id}` for an admin). A school-wide
16551664 read surface is not the place to widen where a phone number is reachable.
16561665
16571666 **Visibility** is every authenticated account reading every profile, with one
migrations/school/20260923000003_person_extra.sqladded+9 -0
@@ -0,0 +1,9 @@
1+-- Profile extras on app_user: gender, postal address, and an emergency
2+-- contact (name + phone). All NULL until filled in; every column rides the
3+-- three-state PATCH (omitted keeps, "" clears, a value validates), exactly
4+-- like phone and birth_date before them.
5+ALTER TABLE app_user
6+ ADD COLUMN gender TEXT NULL CHECK (gender IN ('female', 'male', 'other', 'undisclosed')),
7+ ADD COLUMN address TEXT NULL,
8+ ADD COLUMN emergency_contact_name TEXT NULL,
9+ ADD COLUMN emergency_contact_phone TEXT NULL;
src/constant.rsmodified+3 -2
@@ -35,10 +35,11 @@ pub const MAX_PASSWORD_LEN: usize = 128;
3535
3636 pub const MAX_NAME_LEN: usize = 100;
3737
38-/// Profile fields: the self-chosen name a user is shown under, and the free
39-/// text under it.
38+/// Profile fields: the self-chosen name a user is shown under, the free
39+/// text under it, and the postal address.
4040 pub const MAX_DISPLAY_NAME_LEN: usize = 50;
4141 pub const MAX_BIO_LEN: usize = 500;
42+pub const MAX_ADDRESS_LEN: usize = 500;
4243
4344 /// How many course and class references one profile read embeds. A cap on the
4445 /// response, not on membership — the full lists stay at `/courses/me` and
src/db/user.rsmodified+73 -17
@@ -15,7 +15,7 @@ use crate::domain::board::{Board, BoardId, BoardTitle};
1515 use crate::domain::note_file::FileContentType;
1616 use crate::domain::person::PersonId;
1717 use crate::domain::preferences::{Language, PaletteColor, Theme};
18-use crate::domain::profile::{Bio, BirthDate, DisplayName, Email, PersonName, Phone};
18+use crate::domain::profile::{Address, Bio, BirthDate, DisplayName, Email, Gender, PersonName, Phone};
1919 use crate::domain::role::Role;
2020 use crate::domain::text_fold::{search_fold, search_fold_sql};
2121 use crate::domain::timestamp::Timestamp;
@@ -92,6 +92,10 @@ pub async fn create_with_role(
9292 email AS "email: Email",
9393 phone AS "phone: Phone",
9494 birth_date AS "birth_date: BirthDate",
95+ gender AS "gender: Gender",
96+ address AS "address: Address",
97+ emergency_contact_name AS "emergency_contact_name: PersonName",
98+ emergency_contact_phone AS "emergency_contact_phone: Phone",
9599 theme AS "theme: Theme",
96100 language AS "language: Language",
97101 palette_color AS "palette_color: PaletteColor",
@@ -146,6 +150,10 @@ pub async fn read(db: &Database, id: &UserId) -> Result<Option<User>, AppError>
146150 email AS "email: Email",
147151 phone AS "phone: Phone",
148152 birth_date AS "birth_date: BirthDate",
153+ gender AS "gender: Gender",
154+ address AS "address: Address",
155+ emergency_contact_name AS "emergency_contact_name: PersonName",
156+ emergency_contact_phone AS "emergency_contact_phone: Phone",
149157 theme AS "theme: Theme",
150158 language AS "language: Language",
151159 palette_color AS "palette_color: PaletteColor",
@@ -192,6 +200,10 @@ pub async fn list_by_ids(db: &Database, ids: &[UserId]) -> Result<Vec<User>, App
192200 email AS "email: Email",
193201 phone AS "phone: Phone",
194202 birth_date AS "birth_date: BirthDate",
203+ gender AS "gender: Gender",
204+ address AS "address: Address",
205+ emergency_contact_name AS "emergency_contact_name: PersonName",
206+ emergency_contact_phone AS "emergency_contact_phone: Phone",
195207 theme AS "theme: Theme",
196208 language AS "language: Language",
197209 palette_color AS "palette_color: PaletteColor",
@@ -225,6 +237,10 @@ pub async fn list_by_role(db: &Database, role: Role) -> Result<Vec<User>, AppErr
225237 email AS "email: Email",
226238 phone AS "phone: Phone",
227239 birth_date AS "birth_date: BirthDate",
240+ gender AS "gender: Gender",
241+ address AS "address: Address",
242+ emergency_contact_name AS "emergency_contact_name: PersonName",
243+ emergency_contact_phone AS "emergency_contact_phone: Phone",
228244 theme AS "theme: Theme",
229245 language AS "language: Language",
230246 palette_color AS "palette_color: PaletteColor",
@@ -456,6 +472,10 @@ pub async fn set_role_cascade(
456472 email AS "email: Email",
457473 phone AS "phone: Phone",
458474 birth_date AS "birth_date: BirthDate",
475+ gender AS "gender: Gender",
476+ address AS "address: Address",
477+ emergency_contact_name AS "emergency_contact_name: PersonName",
478+ emergency_contact_phone AS "emergency_contact_phone: Phone",
459479 theme AS "theme: Theme",
460480 language AS "language: Language",
461481 palette_color AS "palette_color: PaletteColor",
@@ -722,6 +742,10 @@ pub async fn set_profile(
722742 birth_date: Option<Option<BirthDate>>,
723743 display_name: Option<Option<DisplayName>>,
724744 bio: Option<Option<Bio>>,
745+ gender: Option<Option<Gender>>,
746+ address: Option<Option<Address>>,
747+ emergency_contact_name: Option<Option<PersonName>>,
748+ emergency_contact_phone: Option<Option<Phone>>,
725749 branch: Option<Option<String>>,
726750 student_number: Option<Option<StudentNumber>>,
727751 ) -> Result<User, AppError> {
@@ -763,6 +787,30 @@ pub async fn set_profile(
763787 "bio",
764788 text(bio.as_ref().map(|n| n.as_ref().map(|x| x.as_str()))),
765789 )
790+ .set(
791+ "gender",
792+ text(gender.as_ref().map(|n| n.as_ref().map(|x| x.as_str()))),
793+ )
794+ .set(
795+ "address",
796+ text(address.as_ref().map(|n| n.as_ref().map(|x| x.as_str()))),
797+ )
798+ .set(
799+ "emergency_contact_name",
800+ text(
801+ emergency_contact_name
802+ .as_ref()
803+ .map(|n| n.as_ref().map(|x| x.as_str())),
804+ ),
805+ )
806+ .set(
807+ "emergency_contact_phone",
808+ text(
809+ emergency_contact_phone
810+ .as_ref()
811+ .map(|n| n.as_ref().map(|x| x.as_str())),
812+ ),
813+ )
766814 // The subject area is plain text, not a newtype: the school's own list is
767815 // settings data, so its membership check belongs to the write path
768816 // that holds that list (the web layer), not to a row type.
@@ -840,6 +888,10 @@ pub async fn set_avatar(
840888 email AS "email: Email",
841889 phone AS "phone: Phone",
842890 birth_date AS "birth_date: BirthDate",
891+ gender AS "gender: Gender",
892+ address AS "address: Address",
893+ emergency_contact_name AS "emergency_contact_name: PersonName",
894+ emergency_contact_phone AS "emergency_contact_phone: Phone",
843895 theme AS "theme: Theme",
844896 language AS "language: Language",
845897 palette_color AS "palette_color: PaletteColor",
@@ -890,6 +942,10 @@ pub async fn clear_avatar(db: &Database, id: &UserId) -> Result<Option<User>, Ap
890942 email AS "email: Email",
891943 phone AS "phone: Phone",
892944 birth_date AS "birth_date: BirthDate",
945+ gender AS "gender: Gender",
946+ address AS "address: Address",
947+ emergency_contact_name AS "emergency_contact_name: PersonName",
948+ emergency_contact_phone AS "emergency_contact_phone: Phone",
893949 theme AS "theme: Theme",
894950 language AS "language: Language",
895951 palette_color AS "palette_color: PaletteColor",
@@ -954,6 +1010,10 @@ pub async fn find_by_username(db: &Database, username: &str) -> Result<Option<Us
9541010 email AS "email: Email",
9551011 phone AS "phone: Phone",
9561012 birth_date AS "birth_date: BirthDate",
1013+ gender AS "gender: Gender",
1014+ address AS "address: Address",
1015+ emergency_contact_name AS "emergency_contact_name: PersonName",
1016+ emergency_contact_phone AS "emergency_contact_phone: Phone",
9571017 theme AS "theme: Theme",
9581018 language AS "language: Language",
9591019 palette_color AS "palette_color: PaletteColor",
@@ -1016,6 +1076,10 @@ mod tests {
10161076 None,
10171077 None,
10181078 None,
1079+ None,
1080+ None,
1081+ None,
1082+ None,
10191083 )
10201084 .await
10211085 .unwrap();
@@ -1048,14 +1112,8 @@ mod tests {
10481112 set_profile(
10491113 &db,
10501114 user.get_id(),
1051- None,
1052- None,
1053- None,
1054- None,
1055- None,
1056- None,
1057- None,
1058- None,
1115+ None, None, None, None, None, None, None, None, // name..bio
1116+ None, None, None, None, // gender..emergency_contact_phone
10591117 Some(Some(number.clone())),
10601118 )
10611119 .await
@@ -1071,14 +1129,8 @@ mod tests {
10711129 let refused = set_profile(
10721130 &db,
10731131 stale.get_id(),
1074- None,
1075- None,
1076- None,
1077- None,
1078- None,
1079- None,
1080- None,
1081- None,
1132+ None, None, None, None, None, None, None, None, // name..bio
1133+ None, None, None, None, // gender..emergency_contact_phone
10821134 Some(Some(number)),
10831135 )
10841136 .await;
@@ -1123,6 +1175,10 @@ mod tests {
11231175 None,
11241176 None,
11251177 None,
1178+ None,
1179+ None,
1180+ None,
1181+ None,
11261182 )
11271183 .await
11281184 .unwrap();
src/domain/profile.rsmodified+93 -1
@@ -1,7 +1,7 @@
11 //! Personal-info newtypes shared by every account role — student, teacher,
22 //! manager, and admin records all carry the same optional contact fields.
33
4-use crate::constant::{MAX_BIO_LEN, MAX_DISPLAY_NAME_LEN, MAX_NAME_LEN};
4+use crate::constant::{MAX_ADDRESS_LEN, MAX_BIO_LEN, MAX_DISPLAY_NAME_LEN, MAX_NAME_LEN};
55 use crate::domain::badge::BadgeStats;
66 use crate::domain::timestamp::Timestamp;
77 use crate::error::ValidationError;
@@ -131,6 +131,69 @@ impl Bio {
131131 }
132132 }
133133
134+/// A person's gender, self-declared and deliberately coarse — the school
135+/// office needs a word for a form, not an identity system. One of four fixed
136+/// wire values (`female`, `male`, `other`, `undisclosed`), stored as the same
137+/// string; `NULL` (never chosen) is a row state, not a fifth value.
138+#[derive(Debug, Clone, Copy, PartialEq, Eq, sqlx::Type)]
139+#[sqlx(type_name = "TEXT", rename_all = "lowercase")]
140+pub enum Gender {
141+ Female,
142+ Male,
143+ Other,
144+ Undisclosed,
145+}
146+
147+impl Gender {
148+ /// The wire/storage form. Must stay in lockstep with `rename_all = "lowercase"`.
149+ pub fn as_str(self) -> &'static str {
150+ match self {
151+ Gender::Female => "female",
152+ Gender::Male => "male",
153+ Gender::Other => "other",
154+ Gender::Undisclosed => "undisclosed",
155+ }
156+ }
157+
158+ /// Parse a wire string into a gender — the inverse of [`Gender::as_str`].
159+ /// The vocabulary is closed, so an unknown value is a plain 400, the same
160+ /// refusal an out-of-vocabulary `theme` gets.
161+ pub fn try_from_str(value: &str) -> Result<Self, ValidationError> {
162+ GENDERS
163+ .into_iter()
164+ .find(|gender| gender.as_str() == value)
165+ .ok_or(ValidationError::Invalid {
166+ field: "gender",
167+ reason: "must be one of: female, male, other, undisclosed",
168+ })
169+ }
170+}
171+
172+pub const GENDERS: [Gender; 4] = [
173+ Gender::Female,
174+ Gender::Male,
175+ Gender::Other,
176+ Gender::Undisclosed,
177+];
178+
179+/// A postal address, [`MAX_ADDRESS_LEN`] characters at most. Free text on
180+/// purpose — addresses do not fit a shape the way a phone number does, and
181+/// enforcing one would only reject real ones. Stored trimmed.
182+#[derive(Debug, Clone, PartialEq, Eq, sqlx::Type)]
183+#[sqlx(transparent)]
184+pub struct Address(String);
185+
186+impl Address {
187+ pub fn try_new(value: &str) -> Result<Self, ValidationError> {
188+ validate_required("address", value, MAX_ADDRESS_LEN)?;
189+ Ok(Self(value.trim().to_string()))
190+ }
191+
192+ pub fn as_str(&self) -> &str {
193+ &self.0
194+ }
195+}
196+
134197 /// The motivational counters on a public profile. Every field is a derived
135198 /// count, never a settable one: zero rows is a true zero, so these are `i64`
136199 /// and never `Option` — a `null` in this API means "never chose", which a
@@ -259,4 +322,33 @@ mod tests {
259322 assert!(Bio::try_new(&"é".repeat(MAX_BIO_LEN)).is_ok());
260323 assert!(Bio::try_new(&"é".repeat(MAX_BIO_LEN + 1)).is_err());
261324 }
325+
326+ #[tokio::test]
327+ async fn gender_parses_the_closed_vocabulary() {
328+ assert_eq!(Gender::try_from_str("female").unwrap(), Gender::Female);
329+ assert_eq!(Gender::try_from_str("male").unwrap().as_str(), "male");
330+ assert_eq!(Gender::try_from_str("other").unwrap(), Gender::Other);
331+ assert_eq!(
332+ Gender::try_from_str("undisclosed").unwrap(),
333+ Gender::Undisclosed
334+ );
335+ // The vocabulary is closed: no synonyms, no case play, no blank.
336+ assert!(Gender::try_from_str("woman").is_err());
337+ assert!(Gender::try_from_str("FEMALE").is_err());
338+ assert!(Gender::try_from_str("").is_err());
339+ }
340+
341+ #[tokio::test]
342+ async fn address_trims_and_respects_the_bound() {
343+ assert_eq!(
344+ Address::try_new(" Çamlık Mah. 2. Sk. No: 7 ")
345+ .unwrap()
346+ .as_str(),
347+ "Çamlık Mah. 2. Sk. No: 7"
348+ );
349+ // Blank is "not given" — the three-state PATCH clears it, never stores it.
350+ assert!(Address::try_new(" ").is_err());
351+ assert!(Address::try_new(&"x".repeat(MAX_ADDRESS_LEN)).is_ok());
352+ assert!(Address::try_new(&"x".repeat(MAX_ADDRESS_LEN + 1)).is_err());
353+ }
262354 }
src/domain/user.rsmodified+30 -1
@@ -14,7 +14,9 @@ use crate::domain::monotonic_id::next_uuid;
1414 use crate::domain::note_file::FileContentType;
1515 use crate::domain::person::PersonId;
1616 use crate::domain::preferences::{Language, PaletteColor, Theme};
17-use crate::domain::profile::{Bio, BirthDate, DisplayName, Email, PersonName, Phone};
17+use crate::domain::profile::{
18+ Address, Bio, BirthDate, DisplayName, Email, Gender, PersonName, Phone,
19+};
1820 use crate::domain::role::Role;
1921 use crate::error::{AppError, ValidationError};
2022 use crate::validate::{validate_password, validate_required, validate_username};
@@ -264,6 +266,13 @@ pub struct User {
264266 pub(crate) email: Option<Email>,
265267 pub(crate) phone: Option<Phone>,
266268 pub(crate) birth_date: Option<BirthDate>,
269+ /// Self-declared gender, a postal address, and who to call when this
270+ /// person is unreachable. Optional like everything above — the same
271+ /// "filled in later, `None` = never chose" contract.
272+ pub(crate) gender: Option<Gender>,
273+ pub(crate) address: Option<Address>,
274+ pub(crate) emergency_contact_name: Option<PersonName>,
275+ pub(crate) emergency_contact_phone: Option<Phone>,
267276 // Frontend UI preferences. Optional like the personal info: `None` means
268277 // "never chose", which the frontend renders as the device preference.
269278 pub(crate) theme: Option<Theme>,
@@ -306,6 +315,10 @@ impl User {
306315 email: None,
307316 phone: None,
308317 birth_date: None,
318+ gender: None,
319+ address: None,
320+ emergency_contact_name: None,
321+ emergency_contact_phone: None,
309322 theme: None,
310323 language: None,
311324 palette_color: None,
@@ -361,6 +374,22 @@ impl User {
361374 self.birth_date.as_ref()
362375 }
363376
377+ pub fn get_gender(&self) -> Option<Gender> {
378+ self.gender
379+ }
380+
381+ pub fn get_address(&self) -> Option<&Address> {
382+ self.address.as_ref()
383+ }
384+
385+ pub fn get_emergency_contact_name(&self) -> Option<&PersonName> {
386+ self.emergency_contact_name.as_ref()
387+ }
388+
389+ pub fn get_emergency_contact_phone(&self) -> Option<&Phone> {
390+ self.emergency_contact_phone.as_ref()
391+ }
392+
364393 pub fn get_theme(&self) -> Option<Theme> {
365394 self.theme
366395 }
src/service/user.rsmodified+11 -1
@@ -9,7 +9,9 @@ use crate::domain::board::Board;
99 use crate::domain::note_file::FileContentType;
1010 use crate::domain::person::PersonId;
1111 use crate::domain::preferences::{Language, PaletteColor, Theme};
12-use crate::domain::profile::{Bio, BirthDate, DisplayName, Email, PersonName, Phone};
12+use crate::domain::profile::{
13+ Address, Bio, BirthDate, DisplayName, Email, Gender, PersonName, Phone,
14+};
1315 use crate::domain::role::Role;
1416 use crate::domain::user::{Password, StudentNumber, User, UserId, Username};
1517 use crate::error::AppError;
@@ -176,6 +178,10 @@ pub async fn set_profile(
176178 birth_date: Option<Option<BirthDate>>,
177179 display_name: Option<Option<DisplayName>>,
178180 bio: Option<Option<Bio>>,
181+ gender: Option<Option<Gender>>,
182+ address: Option<Option<Address>>,
183+ emergency_contact_name: Option<Option<PersonName>>,
184+ emergency_contact_phone: Option<Option<Phone>>,
179185 // The subject specialisation, clearable like `bio`; membership in the
180186 // school's `Settings::get_branches()` list is the caller's check, not this
181187 // one's.
@@ -195,6 +201,10 @@ pub async fn set_profile(
195201 birth_date,
196202 display_name,
197203 bio,
204+ gender,
205+ address,
206+ emergency_contact_name,
207+ emergency_contact_phone,
198208 branch,
199209 student_number,
200210 )
src/web/dto.rsmodified+22 -0
@@ -182,6 +182,20 @@ pub struct UserResponse {
182182 pub phone: Option<String>,
183183 #[schema(example = "1990-01-02")]
184184 pub birth_date: Option<String>,
185+ /// Self-declared gender: `female`, `male`, `other`, or `undisclosed`;
186+ /// `null` = never chosen.
187+ #[schema(example = "female")]
188+ pub gender: Option<String>,
189+ /// Postal address; `null` when unset, at most `max_address_len` characters.
190+ #[schema(example = "Çamlık Mah. 2. Sk. No: 7, Bornova / İzmir")]
191+ pub address: Option<String>,
192+ /// Who to call when this person is unreachable; `null` when unset. Same
193+ /// gate as the other contact fields — never on the public profile.
194+ #[schema(example = "Mehmet Yılmaz")]
195+ pub emergency_contact_name: Option<String>,
196+ /// The emergency contact's phone, same shape as `phone`; `null` when unset.
197+ #[schema(example = "+90 555 987 65 43")]
198+ pub emergency_contact_phone: Option<String>,
185199 /// UI color scheme: `light` or `dark`. `null` = never chosen — the client
186200 /// should fall back to the device preference.
187201 #[schema(example = "dark")]
@@ -218,6 +232,14 @@ impl UserResponse {
218232 email: user.get_email().map(|v| v.as_str().to_string()),
219233 phone: user.get_phone().map(|v| v.as_str().to_string()),
220234 birth_date: user.get_birth_date().map(|v| v.as_str().to_string()),
235+ gender: user.get_gender().map(|v| v.as_str().to_string()),
236+ address: user.get_address().map(|v| v.as_str().to_string()),
237+ emergency_contact_name: user
238+ .get_emergency_contact_name()
239+ .map(|v| v.as_str().to_string()),
240+ emergency_contact_phone: user
241+ .get_emergency_contact_phone()
242+ .map(|v| v.as_str().to_string()),
221243 theme: user.get_theme().map(|v| v.as_str().to_string()),
222244 language: user.get_language().map(|v| v.as_str().to_string()),
223245 palette_color: user.get_palette_color().map(|v| v.as_str().to_string()),
src/web/limits.rsmodified+8 -0
@@ -21,6 +21,7 @@ use utoipa_axum::routes;
2121 use crate::constant::*;
2222 use crate::domain::badge::BADGES;
2323 use crate::domain::preferences::{LANGUAGES, THEMES};
24+use crate::domain::profile::GENDERS;
2425 use crate::domain::role::ROLES;
2526 use crate::state::AppState;
2627
@@ -47,6 +48,8 @@ struct UserLimits {
4748 max_display_name_len: usize,
4849 /// Free text under a profile's name.
4950 max_bio_len: usize,
51+ /// A postal address's length bound.
52+ max_address_len: usize,
5053 /// A student number's length bound (free text; unique inside the school,
5154 /// and only ever held by a `student` account).
5255 max_student_number_len: usize,
@@ -68,6 +71,9 @@ struct UserLimits {
6871 /// Accepted `language` preference values (`null` clears it).
6972 #[schema(example = json!(["tr", "en"]))]
7073 languages: Vec<&'static str>,
74+ /// Accepted `gender` profile values (`null` = never chosen).
75+ #[schema(example = json!(["female", "male", "other", "undisclosed"]))]
76+ genders: Vec<&'static str>,
7177 /// Shape a `palette_color` preference must match, as a regular expression
7278 /// (`null` clears it). Open on purpose — any hex accent color, not a fixed
7379 /// palette — so this is a pattern, not a value list like `themes`. Matches
@@ -538,6 +544,7 @@ impl LimitsResponse {
538544 max_name_len: MAX_NAME_LEN,
539545 max_display_name_len: MAX_DISPLAY_NAME_LEN,
540546 max_bio_len: MAX_BIO_LEN,
547+ max_address_len: MAX_ADDRESS_LEN,
541548 max_student_number_len: MAX_STUDENT_NUMBER_LEN,
542549 max_profile_courses: MAX_PROFILE_COURSES,
543550 max_profile_classes: MAX_PROFILE_CLASSES,
@@ -547,6 +554,7 @@ impl LimitsResponse {
547554 roles: ROLES.iter().map(|role| role.as_str()).collect(),
548555 themes: THEMES.iter().map(|theme| theme.as_str()).collect(),
549556 languages: LANGUAGES.iter().map(|language| language.as_str()).collect(),
557+ genders: GENDERS.iter().map(|gender| gender.as_str()).collect(),
550558 palette_color_pattern: PALETTE_COLOR_PATTERN,
551559 palette_color_len: PALETTE_COLOR_LEN,
552560 session_duration_days: SESSION_DURATION_DAYS,
src/web/users.rsmodified+27 -1
@@ -18,7 +18,9 @@ use crate::domain::badge::{self, BadgeAward};
1818 use crate::domain::class_group::ClassGroupId;
1919
2020 use crate::domain::preferences::{Language, PaletteColor, Theme};
21-use crate::domain::profile::{Bio, BirthDate, DisplayName, Email, PersonName, Phone, ProfileStats};
21+use crate::domain::profile::{
22+ Address, Bio, BirthDate, DisplayName, Email, Gender, PersonName, Phone, ProfileStats,
23+};
2224 use crate::domain::role::Role;
2325 use crate::domain::user::{Password, StudentNumber, User, UserId, Username};
2426 use crate::error::{AppError, ErrorResponse, ValidationError};
@@ -94,6 +96,19 @@ struct UpdateProfile {
9496 /// Free text under the profile's name.
9597 #[schema(example = "Sınıfın en hızlı pomodorocusu.", max_length = 500)]
9698 bio: Option<String>,
99+ /// Self-declared gender: `female`, `male`, `other`, or `undisclosed`.
100+ /// A closed vocabulary — anything else is a `400`.
101+ #[schema(example = "female")]
102+ gender: Option<String>,
103+ /// Postal address, at most `max_address_len` characters (from `GET /limits`).
104+ #[schema(example = "Çamlık Mah. 2. Sk. No: 7, Bornova / İzmir", max_length = 500)]
105+ address: Option<String>,
106+ /// Who to call when the person is unreachable. Same rules as `name`.
107+ #[schema(example = "Mehmet Yılmaz", max_length = 100)]
108+ emergency_contact_name: Option<String>,
109+ /// The emergency contact's phone, same shape as `phone`.
110+ #[schema(example = "+90 555 987 65 43")]
111+ emergency_contact_phone: Option<String>,
97112 /// The teacher's subject specialisation: one of the school's `branches` from
98113 /// `GET /settings`, by name. Omit to keep the current value; send `""` to
99114 /// clear it (a school that lists no subjects stores none).
@@ -220,6 +235,13 @@ async fn apply_profile(
220235 let birth_date = merge_field(req.birth_date.as_deref(), BirthDate::try_new)?;
221236 let display_name = merge_field(req.display_name.as_deref(), DisplayName::try_new)?;
222237 let bio = merge_field(req.bio.as_deref(), Bio::try_new)?;
238+ let gender = merge_field(req.gender.as_deref(), Gender::try_from_str)?;
239+ let address = merge_field(req.address.as_deref(), Address::try_new)?;
240+ let emergency_contact_name = merge_field(req.emergency_contact_name.as_deref(), |v| {
241+ PersonName::try_new("emergency_contact_name", v)
242+ })?;
243+ let emergency_contact_phone =
244+ merge_field(req.emergency_contact_phone.as_deref(), Phone::try_new)?;
223245 let student_number = merge_student_number(req.student_number.as_deref(), user.get_role())?;
224246 // Only a request that actually names a branch pays the settings read.
225247 let branch = match req.branch {
@@ -239,6 +261,10 @@ async fn apply_profile(
239261 birth_date,
240262 display_name,
241263 bio,
264+ gender,
265+ address,
266+ emergency_contact_name,
267+ emergency_contact_phone,
242268 branch,
243269 student_number,
244270 )
tests/integration.rsmodified+105 -0
@@ -5649,6 +5649,111 @@ async fn profile_rejects_invalid_fields() {
56495649 }
56505650 }
56515651
5652+// --- users: gender, address, emergency contact ------------------------------
5653+
5654+#[tokio::test]
5655+async fn profile_extra_fields_round_trip_via_users_me() {
5656+ let app = mem_app().await;
5657+ let bob = login(&app, "bob").await;
5658+
5659+ // A fresh account carries none of the extras.
5660+ let me = send(&app, "GET", "/auth/me", Some(&bob), None).await;
5661+ assert_eq!(me.status, StatusCode::OK);
5662+ for field in [
5663+ "gender",
5664+ "address",
5665+ "emergency_contact_name",
5666+ "emergency_contact_phone",
5667+ ] {
5668+ assert!(me.body[field].is_null(), "{field} should start null");
5669+ }
5670+
5671+ // Set all four in one patch.
5672+ let res = send(
5673+ &app,
5674+ "PATCH",
5675+ "/users/me",
5676+ Some(&bob),
5677+ Some(json!({
5678+ "gender": "female",
5679+ "address": " Çamlık Mah. 2. Sk. No: 7 ",
5680+ "emergency_contact_name": "Mehmet Yılmaz",
5681+ "emergency_contact_phone": "+90 555 987 65 43",
5682+ })),
5683+ )
5684+ .await;
5685+ assert_eq!(res.status, StatusCode::OK, "{}", res.body);
5686+ assert_eq!(res.body["gender"], "female");
5687+ assert_eq!(res.body["address"], "Çamlık Mah. 2. Sk. No: 7"); // trimmed
5688+ assert_eq!(res.body["emergency_contact_name"], "Mehmet Yılmaz");
5689+ assert_eq!(res.body["emergency_contact_phone"], "+90 555 987 65 43");
5690+
5691+ // Partial patch: only the address changes, everything else survives.
5692+ let res = send(
5693+ &app,
5694+ "PATCH",
5695+ "/users/me",
5696+ Some(&bob),
5697+ Some(json!({ "address": "Yeni Mah." })),
5698+ )
5699+ .await;
5700+ assert_eq!(res.status, StatusCode::OK);
5701+ assert_eq!(res.body["address"], "Yeni Mah.");
5702+ assert_eq!(res.body["gender"], "female");
5703+ assert_eq!(res.body["emergency_contact_name"], "Mehmet Yılmaz");
5704+ assert_eq!(res.body["emergency_contact_phone"], "+90 555 987 65 43");
5705+
5706+ // Empty string clears exactly the field it was sent for.
5707+ let res = send(
5708+ &app,
5709+ "PATCH",
5710+ "/users/me",
5711+ Some(&bob),
5712+ Some(json!({ "gender": "" })),
5713+ )
5714+ .await;
5715+ assert_eq!(res.status, StatusCode::OK);
5716+ assert!(res.body["gender"].is_null());
5717+ assert_eq!(res.body["address"], "Yeni Mah.");
5718+
5719+ // The merged state is what /auth/me reports afterwards.
5720+ let me = send(&app, "GET", "/auth/me", Some(&bob), None).await;
5721+ assert!(me.body["gender"].is_null());
5722+ assert_eq!(me.body["address"], "Yeni Mah.");
5723+ assert_eq!(me.body["emergency_contact_phone"], "+90 555 987 65 43");
5724+}
5725+
5726+#[tokio::test]
5727+async fn profile_rejects_invalid_extra_fields() {
5728+ let app = mem_app().await;
5729+ let bob = login(&app, "bob").await;
5730+
5731+ let bad = [
5732+ json!({ "gender": "woman" }), // not in the vocabulary
5733+ json!({ "gender": "FEMALE" }), // the vocabulary is lowercase
5734+ json!({ "address": "x".repeat(501) }), // one over the bound
5735+ json!({ "address": " " }), // whitespace-only is not a value
5736+ json!({ "emergency_contact_phone": "123" }),
5737+ json!({ "emergency_contact_phone": "letters" }),
5738+ json!({ "emergency_contact_name": " " }),
5739+ ];
5740+ for body in bad {
5741+ let res = send(&app, "PATCH", "/users/me", Some(&bob), Some(body.clone())).await;
5742+ assert_eq!(res.status, StatusCode::BAD_REQUEST, "should reject {body}");
5743+ }
5744+
5745+ // A rejected patch must not have half-applied.
5746+ let me = send(&app, "GET", "/auth/me", Some(&bob), None).await;
5747+ for field in [
5748+ "gender",
5749+ "address",
5750+ "emergency_contact_name",
5751+ "emergency_contact_phone",
5752+ ] {
5753+ assert!(me.body[field].is_null(), "{field} should still be null");
5754+ }
5755+}
5756+
56525757 #[tokio::test]
56535758 async fn admin_reads_and_edits_any_profile_with_guards() {
56545759 let (app, db) = app_and_db().await;
tests/limits_completeness.rsmodified+1 -0
@@ -503,6 +503,7 @@ const MOVED_TABLES: &[(&str, &str)] = &[
503503 ("src/domain/role.rs", "ROLES"),
504504 ("src/domain/preferences.rs", "THEMES"),
505505 ("src/domain/preferences.rs", "LANGUAGES"),
506+ ("src/domain/profile.rs", "GENDERS"),
506507 ("src/domain/message.rs", "SENDER_FOLDERS"),
507508 ("src/domain/message.rs", "RECIPIENT_FOLDERS"),
508509 ("src/domain/badge.rs", "BADGES"),
tests/partial_patch_users.rsmodified+58 -0
@@ -210,3 +210,61 @@ async fn omitted_keeps_empty_clears_and_validation_still_bites() {
210210 "bad palette color refused"
211211 );
212212 }
213+
214+/// The new profile extras ride the same three-state merge: omitted (and
215+/// `null`) keeps, `""` clears, and an out-of-vocabulary value is a `400` —
216+/// the field inventory must not grow into a second, looser code path.
217+#[tokio::test]
218+async fn extra_profile_fields_merge_field_by_field() {
219+ let (app, db) = app_and_db().await;
220+ let who = login_as(&app, &db, "ece", "student").await;
221+
222+ let set = send(
223+ &app,
224+ "PATCH",
225+ "/users/me",
226+ Some(&who),
227+ Some(json!({ "gender": "other", "address": "Deniz Mah." })),
228+ )
229+ .await;
230+ assert_eq!(set.status, StatusCode::OK, "{}", set.body);
231+
232+ // An explicit null keeps, and the field not named survives untouched.
233+ let kept = send(
234+ &app,
235+ "PATCH",
236+ "/users/me",
237+ Some(&who),
238+ Some(json!({ "address": null })),
239+ )
240+ .await;
241+ assert_eq!(kept.status, StatusCode::OK);
242+ assert_eq!(kept.body["gender"], "other", "omitted gender kept");
243+ assert_eq!(kept.body["address"], "Deniz Mah.", "null keeps address");
244+
245+ // `""` clears one field; the other stays.
246+ let cleared = send(
247+ &app,
248+ "PATCH",
249+ "/users/me",
250+ Some(&who),
251+ Some(json!({ "address": "" })),
252+ )
253+ .await;
254+ assert_eq!(cleared.status, StatusCode::OK);
255+ assert_eq!(cleared.body["address"], json!(null));
256+ assert_eq!(cleared.body["gender"], "other", "gender lost to the clear");
257+
258+ // The gender vocabulary is closed: an unknown word is a 400.
259+ let refused = send(
260+ &app,
261+ "PATCH",
262+ "/users/me",
263+ Some(&who),
264+ Some(json!({ "gender": "woman" })),
265+ )
266+ .await;
267+ assert_eq!(refused.status, StatusCode::BAD_REQUEST);
268+ let after = send(&app, "GET", "/auth/me", Some(&who), None).await.body;
269+ assert_eq!(after["gender"], "other", "a refused patch writes nothing");
270+}
tests/regress_profile.rsmodified+13 -1
@@ -99,6 +99,10 @@ async fn a_peer_profile_carries_no_contact_fields() {
9999 "email": "ada@example.com",
100100 "phone": "+90 555 123 45 67",
101101 "birth_date": "1990-01-02",
102+ "gender": "female",
103+ "address": "Çamlık Mah. 2. Sk. No: 7, Bornova / İzmir",
104+ "emergency_contact_name": "Mehmet Yılmaz",
105+ "emergency_contact_phone": "+90 555 987 65 43",
102106 })),
103107 )
104108 .await;
@@ -107,7 +111,15 @@ async fn a_peer_profile_carries_no_contact_fields() {
107111 let seen = profile(&app, &peer, &ada_id).await;
108112 assert_eq!(seen.status, StatusCode::OK, "{}", seen.body);
109113 assert_eq!(seen.body["username"], "ada");
110- for private in ["email", "phone", "birth_date"] {
114+ for private in [
115+ "email",
116+ "phone",
117+ "birth_date",
118+ "gender",
119+ "address",
120+ "emergency_contact_name",
121+ "emergency_contact_phone",
122+ ] {
111123 assert!(
112124 seen.body.get(private).is_none(),
113125 "{private} must not ride on a profile: {}",
tests/spec_bounds.rsmodified+9 -0
@@ -246,6 +246,15 @@ fn expectations() -> Vec<(&'static str, &'static str, &'static str, i64)> {
246246 MAX_DISPLAY_NAME_LEN as i64,
247247 ),
248248 ("UpdateProfile", "bio", "maxLength", MAX_BIO_LEN as i64),
249+ // Free text with the same length cap the bio has.
250+ ("UpdateProfile", "address", "maxLength", MAX_ADDRESS_LEN as i64),
251+ // The emergency contact is a person's name, held to the same bound.
252+ (
253+ "UpdateProfile",
254+ "emergency_contact_name",
255+ "maxLength",
256+ MAX_NAME_LEN as i64,
257+ ),
249258 // A branş is one entry of the school's `branches` list, so it is
250259 // bounded by the same per-entry length the list itself is.
251260 (