@@ -182,5 +182,53 @@ export const useUserStore = defineStore("UserStore", {
182
182
this . user = null ;
183
183
this . loginError = null ;
184
184
} ,
185
+
186
+ // SGC User Management Methods - calls data-registry-api which handles user service tokens
187
+ async createSGCUser ( userData , userType ) {
188
+ try {
189
+ const config = useRuntimeConfig ( ) ;
190
+ const sgcAxios = useSGCAxios ( config ) ;
191
+
192
+ const response = await sgcAxios . post ( '/api/sgc/create-user' , {
193
+ user_name : userData . email , // Email serves as both username and email
194
+ password : userData . password ,
195
+ email : userData . email || '' ,
196
+ first_name : userData . firstName || '' ,
197
+ last_name : userData . lastName || '' ,
198
+ user_type : userType // 'reviewer' or 'uploader'
199
+ } ) ;
200
+
201
+ return response . data ;
202
+ } catch ( error ) {
203
+ console . error ( 'SGC user creation error:' , error ) ;
204
+ throw error ;
205
+ }
206
+ } ,
207
+
208
+ // Get list of SGC users (if needed for management interface)
209
+ async getSGCUsers ( ) {
210
+ try {
211
+ const config = useRuntimeConfig ( ) ;
212
+ const sgcAxios = useSGCAxios ( config ) ;
213
+
214
+ const response = await sgcAxios . get ( '/api/sgc/users' ) ;
215
+ return response . data ;
216
+ } catch ( error ) {
217
+ console . error ( 'Error fetching SGC users:' , error ) ;
218
+ throw error ;
219
+ }
220
+ } ,
221
+
222
+ // Check if current user has permission to manage users
223
+ canManageUsers ( ) {
224
+ if ( ! this . user ) {
225
+ return false ;
226
+ }
227
+
228
+ // Check if user has reviewer role or manage_users permission
229
+ return this . user . roles ?. includes ( 'sgc-reviewer' ) ||
230
+ this . user . permissions ?. includes ( 'manage_users' ) ||
231
+ this . user . roles ?. includes ( 'reviewer' ) ;
232
+ } ,
185
233
} ,
186
234
} ) ;
0 commit comments