add property to control user updates
This commit is contained in:
parent
caf3ff79a3
commit
da8dafb627
@ -1 +1 @@
|
|||||||
__version__ = "1.0.7"
|
__version__ = "1.0.8"
|
||||||
|
@ -110,6 +110,9 @@ class WPOpenEdxOAuth2(BaseOAuth2):
|
|||||||
# changed to a list. example 'basic, email, profile'. This
|
# changed to a list. example 'basic, email, profile'. This
|
||||||
# list can be delimited with commas, spaces, whatever.
|
# list can be delimited with commas, spaces, whatever.
|
||||||
SCOPE_SEPARATOR = " "
|
SCOPE_SEPARATOR = " "
|
||||||
|
|
||||||
|
# Enable updates on the Django user object on successful WordPress login.
|
||||||
|
UPDATE_USER_ON_LOGIN = True
|
||||||
|
|
||||||
# private utility function. not part of psa.
|
# private utility function. not part of psa.
|
||||||
def _urlopen(self, url):
|
def _urlopen(self, url):
|
||||||
@ -409,28 +412,28 @@ class WPOpenEdxOAuth2(BaseOAuth2):
|
|||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return self.user_details
|
return self.user_details
|
||||||
|
|
||||||
if (user.is_superuser != self.user_details["is_superuser"]) or (
|
if self.UPDATE_USER_ON_LOGIN:
|
||||||
user.is_staff != self.user_details["is_staff"]
|
if (user.is_superuser != self.user_details["is_superuser"]) or (
|
||||||
):
|
user.is_staff != self.user_details["is_staff"]
|
||||||
user.is_superuser = self.user_details["is_superuser"]
|
):
|
||||||
user.is_staff = self.user_details["is_staff"]
|
user.is_superuser = self.user_details["is_superuser"]
|
||||||
user.save()
|
user.is_staff = self.user_details["is_staff"]
|
||||||
logger.info(
|
user.save()
|
||||||
"Updated the is_superuser/is_staff flags for user {username}".format(
|
logger.info(
|
||||||
username=user.username
|
"Updated the is_superuser/is_staff flags for user {username}".format(
|
||||||
|
username=user.username
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
if (user.first_name != self.user_details["first_name"]) or (
|
||||||
|
user.last_name != self.user_details["last_name"]
|
||||||
if (user.first_name != self.user_details["first_name"]) or (
|
):
|
||||||
user.last_name != self.user_details["last_name"]
|
user.first_name = self.user_details["first_name"]
|
||||||
):
|
user.last_name = self.user_details["last_name"]
|
||||||
user.first_name = self.user_details["first_name"]
|
user.save()
|
||||||
user.last_name = self.user_details["last_name"]
|
logger.info(
|
||||||
user.save()
|
"Updated first_name/last_name for user {username}".format(
|
||||||
logger.info(
|
username=user.username
|
||||||
"Updated first_name/last_name for user {username}".format(
|
)
|
||||||
username=user.username
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
return self.user_details
|
return self.user_details
|
||||||
|
Loading…
Reference in New Issue
Block a user