@@ -50,10 +50,17 @@ static int wh_DemoClient_AuthPin(whClientContext* clientContext)
5050 /* login as the admin and add a new user */
5151 rc = wh_Client_AuthLogin (clientContext ,
5252 WH_AUTH_METHOD_PIN , "admin" , "1234" , 4 , & serverRc , & adminUserId );
53+ if (serverRc == WH_AUTH_NOT_ENABLED ) {
54+ printf ("[AUTH-DEMO] Authentication not enabled on server, "
55+ "skipping PIN demo.\n" );
56+ return WH_ERROR_OK ;
57+ }
58+
5359 if (rc != 0 ) {
5460 printf ("[AUTH-DEMO] Failed to login as admin: %d\n" , rc );
5561 return rc ;
5662 }
63+
5764 if (serverRc != 0 ) {
5865 printf ("[AUTH-DEMO] Server-side error logging in as admin: %d\n" ,
5966 (int )serverRc );
@@ -198,6 +205,12 @@ static int wh_DemoClient_AuthCertificate(whClientContext* clientContext)
198205 "1234" , 4 ,
199206 & serverRc ,
200207 & adminUserId );
208+ if (serverRc == WH_AUTH_NOT_ENABLED ) {
209+ printf ("[AUTH-DEMO] Authentication not enabled on server, "
210+ "skipping certificate demo.\n" );
211+ return WH_ERROR_OK ;
212+ }
213+
201214 if (rc != 0 ) {
202215 printf ("[AUTH-DEMO] Failed to login as admin: %d\n" , rc );
203216 return rc ;
@@ -273,9 +286,16 @@ static int wh_DemoClient_AuthUserDelete(whClientContext* clientContext)
273286 "1234" , 4 ,
274287 & serverRc ,
275288 & adminUserId );
289+ if (serverRc == WH_AUTH_NOT_ENABLED ) {
290+ printf ("[AUTH-DEMO] Authentication not enabled on server, "
291+ "skipping user delete demo.\n" );
292+ return WH_ERROR_OK ;
293+ }
294+
276295 if (rc != 0 ) {
277296 return rc ;
278297 }
298+
279299 if (serverRc != 0 ) {
280300 return (int )serverRc ;
281301 }
@@ -328,6 +348,12 @@ static int wh_DemoClient_AuthUserSetPermissions(whClientContext* clientContext)
328348 "1234" , 4 ,
329349 & serverRc ,
330350 & adminUserId );
351+ if (serverRc == WH_AUTH_NOT_ENABLED ) {
352+ printf ("[AUTH-DEMO] Authentication not enabled on server, "
353+ "skipping user set permissions demo.\n" );
354+ return WH_ERROR_OK ;
355+ }
356+
331357 if (rc != 0 ) {
332358 return rc ;
333359 }
@@ -394,22 +420,22 @@ int wh_DemoClient_Auth(whClientContext* clientContext)
394420
395421 printf ("[AUTH-DEMO] Starting authentication demo...\n" );
396422 rc = wh_DemoClient_AuthCertificate (clientContext );
397- if (rc != 0 ) {
423+ if (rc != WH_ERROR_OK ) {
398424 return rc ;
399425 }
400426
401427 rc = wh_DemoClient_AuthPin (clientContext );
402- if (rc != 0 ) {
428+ if (rc != WH_ERROR_OK ) {
403429 return rc ;
404430 }
405431
406432 rc = wh_DemoClient_AuthUserDelete (clientContext );
407- if (rc != 0 ) {
433+ if (rc != WH_ERROR_OK ) {
408434 return rc ;
409435 }
410436
411437 rc = wh_DemoClient_AuthUserSetPermissions (clientContext );
412- if (rc != 0 ) {
438+ if (rc != WH_ERROR_OK ) {
413439 return rc ;
414440 }
415441 printf ("[AUTH-DEMO] Authentication demo completed.\n" );
0 commit comments