Feature 10914: Enforce Password change on First login
[osm/osmclient.git] / osmclient / sol005 / client.py
index c7f043b..b6f12b3 100644 (file)
@@ -40,6 +40,7 @@ from osmclient.sol005 import repo
 from osmclient.sol005 import osmrepo
 from osmclient.sol005 import subscription
 from osmclient.common import package_tool
+from osmclient.common.exceptions import ClientException
 import json
 import logging
 
@@ -107,7 +108,7 @@ class Client(object):
         self.utils = utils.Utils(http_client, **kwargs)
         """
 
-    def get_token(self):
+    def get_token(self, pwd_change=None):
         self._logger.debug("")
         if self._token is None:
             postfields_dict = {
@@ -129,6 +130,8 @@ class Client(object):
             #                raise ClientException(message)
 
             token = json.loads(resp) if resp else None
+            if token.get("message") == "change_password" and not pwd_change:
+                raise ClientException("Password Expired. Please update the password using change_password option")
             self._token = token["id"]
 
             if self._token is not None: