@@ -127,7 +127,7 @@ export const processRegistrations = async (req, res) => {
127127 firstName,
128128 lastName,
129129 email,
130- position, // This will be used as role
130+ position, // This will be used as role and position
131131 department,
132132 phoneNumber : phone = '' ,
133133 address = '' ,
@@ -153,9 +153,9 @@ export const processRegistrations = async (req, res) => {
153153 const saltRounds = 10 ;
154154 const hashedPassword = await bcryptjs . hash ( generatedPassword , saltRounds ) ;
155155
156- // Normalize fields - use formatDepartment instead of capitalizeFirstLetter
156+ // Normalize fields
157157 const normalizedDepartment = formatDepartment ( department ) ;
158- const normalizedRole = position . trim ( ) ; // Using position as role as requested
158+ const normalizedRole = position . trim ( ) . toLowerCase ( ) ; // Using position as role
159159
160160 // Prepare user data
161161 const userData = {
@@ -165,6 +165,7 @@ export const processRegistrations = async (req, res) => {
165165 email,
166166 password : hashedPassword ,
167167 role : normalizedRole ,
168+ position : position . trim ( ) , // Set position explicitly
168169 department : normalizedDepartment ,
169170 phoneNumber : phone || '0000000000' ,
170171 username : generateUsername ( normalizedRole ) ,
@@ -312,7 +313,7 @@ export const saveUser = async (req, res) => {
312313 const saltRounds = 10 ;
313314 const hashedPassword = await bcryptjs . hash ( generatedPassword , saltRounds ) ;
314315
315- // Normalize and validate department and role - use formatDepartment instead of capitalizeFirstLetter
316+ // Normalize and validate department and role
316317 const normalizedDepartment = formatDepartment ( department ) ;
317318 const normalizedRole = role . toLowerCase ( ) . trim ( ) ;
318319
@@ -324,6 +325,7 @@ export const saveUser = async (req, res) => {
324325 email,
325326 password : hashedPassword , // Store hashed password
326327 role : normalizedRole ,
328+ position : role . trim ( ) , // Add position field with the original role value
327329 department : normalizedDepartment ,
328330 phoneNumber : phone || '0000000000' ,
329331 username : generateUsername ( normalizedRole ) ,
0 commit comments