Browse Source

Fix error message

Laurent Destailleur 3 years ago
parent
commit
1efbff8fea
1 changed files with 5 additions and 1 deletions
  1. 5 1
      htdocs/api/class/api_login.class.php

+ 5 - 1
htdocs/api/class/api_login.class.php

@@ -135,7 +135,11 @@ class Login
 		if (empty($tmpuser->api_key) || $reset) {
 			$tmpuser->getrights();
 			if (empty($tmpuser->rights->user->self->creer)) {
-				throw new RestException(403, 'User need write permission on itself to reset its API token');
+				if (empty($tmpuser->api_key)) {
+					throw new RestException(403, 'No API token set for this user and user need write permission on itself to reset its API token');
+				} else {
+					throw new RestException(403, 'User need write permission on itself to reset its API token');
+				}
 			}
 
 			// Generate token for user