From 2a355496312a6dc3a7ec73fff0fb84429a8a7796 Mon Sep 17 00:00:00 2001
From: Shaily <shaily15297@yahoo.com>
Date: Jan 25 2018 08:19:59 +0000
Subject: [PATCH 1/2] Address private fields in FAS


---

diff --git a/hubs/static/client/app/components/UserContact.js b/hubs/static/client/app/components/UserContact.js
index 471d7e4..b1859ef 100644
--- a/hubs/static/client/app/components/UserContact.js
+++ b/hubs/static/client/app/components/UserContact.js
@@ -12,41 +12,51 @@ export default class UserContact extends React.Component {
     return (
       <div className="UserContact">
         <ul className="fa-ul">
-          <li>
-            <i className="fa fa-li fa-map-marker" aria-hidden="true"></i>
-            <span className="ml-2">
+          { this.props.hub.config.country &&
+            <li>
+              <i className="fa fa-li fa-map-marker" aria-hidden="true"></i>
+              <span className="ml-2">
                 {this.props.hub.config.country}
             </span>
-          </li>
-          <li>
-            <i className="fa fa-li fa-clock-o" aria-hidden="true"></i>
-            <span className="ml-2 mr-1">Current Time:</span>
-            <CurrentTime offset={this.props.hub.config.timezone_offset} />
-          </li>
-          <li>
-            <i className="fa fa-li fa-envelope-o" aria-hidden="true"></i>
-            <span className="ml-2">
+            </li>
+          }
+          { this.props.hub.config.timezone_offset &&
+            <li>
+              <i className="fa fa-li fa-clock-o" aria-hidden="true"></i>
+              <span className="ml-2 mr-1">Current Time:</span>
+              <CurrentTime offset={this.props.hub.config.timezone_offset}/>
+            </li>
+          }
+          { this.props.hub.config.email &&
+            <li>
+              <i className="fa fa-li fa-envelope-o" aria-hidden="true"></i>
+              <span className="ml-2">
               {this.props.hub.config.email}
             </span>
-          </li>
-          <li>
-            <i className="fa fa-li fa-comment-o" aria-hidden="true"></i>
-            <span className="ml-2">
+            </li>
+          }
+          { this.props.hub.config.chat_nickname &&
+            <li>
+              <i className="fa fa-li fa-comment-o" aria-hidden="true"></i>
+              <span className="ml-2">
               {this.props.hub.config.chat_nickname}
             </span>
-          </li>
+            </li>
+          }
         </ul>
-        <div className="text-center">
-          <i className="fa fa-certificate" aria-hidden="true"></i>
-          <span className="ml-2 mr-1">
+        { this.props.hub.config.creation_date &&
+          <div className="text-center">
+            <i className="fa fa-certificate" aria-hidden="true"></i>
+            <span className="ml-2 mr-1">
             Member Since
           </span>
-          <FormattedDate
-            value={Date.parse(this.props.hub.config.creation_date)}
-            month="short"
-            year="numeric"
+            <FormattedDate
+              value={Date.parse(this.props.hub.config.creation_date)}
+              month="short"
+              year="numeric"
             />
-        </div>
+          </div>
+        }
       </div>
     );
   }
diff --git a/hubs/utils/fas.py b/hubs/utils/fas.py
index a992ebf..6805eb6 100644
--- a/hubs/utils/fas.py
+++ b/hubs/utils/fas.py
@@ -120,13 +120,14 @@ class FASClient(object):
             if fas_user[fas_attr] is None:
                 continue
             hub.config[hub_attr] = fas_user[fas_attr]
-        country = pycountry.countries.get(alpha_2=fas_user["country_code"])
-        hub.config["country"] = country.name
-        # Timezone
-        now = datetime.datetime.now()  # does not really matter, legacy API
-        tz_offset = timezone(fas_user["timezone"]).utcoffset(now)
-        hub.config["timezone_offset"] = (
-            tz_offset.days * 86400 + tz_offset.seconds)
+        if fas_user["country_code"] is not None:
+            country = pycountry.countries.get(alpha_2=fas_user["country_code"])
+            hub.config["country"] = country.name
+        if fas_user["timezone"] is not None:
+            now = datetime.datetime.now()  # does not really matter, legacy API
+            tz_offset = timezone(fas_user["timezone"]).utcoffset(now)
+            hub.config["timezone_offset"] = (
+                tz_offset.days * 86400 + tz_offset.seconds)
         return fas_user
 
     def sync_user_roles(self, user, hub=None):

From 2d8ca5c97c8f1cc0673f1027f45fc65c4efac5c8 Mon Sep 17 00:00:00 2001
From: Shaily <shaily15297@yahoo.com>
Date: Jan 25 2018 08:19:59 +0000
Subject: [PATCH 2/2] FAS private fields: Changes from review


---

diff --git a/hubs/utils/fas.py b/hubs/utils/fas.py
index 6805eb6..98b782b 100644
--- a/hubs/utils/fas.py
+++ b/hubs/utils/fas.py
@@ -120,10 +120,10 @@ class FASClient(object):
             if fas_user[fas_attr] is None:
                 continue
             hub.config[hub_attr] = fas_user[fas_attr]
-        if fas_user["country_code"] is not None:
+        if fas_user.get("country_code") is not None:
             country = pycountry.countries.get(alpha_2=fas_user["country_code"])
             hub.config["country"] = country.name
-        if fas_user["timezone"] is not None:
+        if fas_user.get("timezone") is not None:
             now = datetime.datetime.now()  # does not really matter, legacy API
             tz_offset = timezone(fas_user["timezone"]).utcoffset(now)
             hub.config["timezone_offset"] = (

