def require_email(backend, details, weblate_action, user=None, is_new=False, **kwargs): """Force entering email for backends which don't provide it.""" if backend.name == 'github': email = get_github_email(kwargs['response']['access_token']) if email is not None: details['email'] = email # Remove any pending email validation codes if details.get('email') and backend.name == 'email': invalidate_reset_codes(emails=(details['email'], )) # Remove all account reset codes if user and weblate_action == 'reset': invalidate_reset_codes(user=user) if user and user.email: # Force validation of new email address if backend.name == 'email': return {'is_new': True} return None elif is_new and not details.get('email'): raise AuthMissingParameter(backend, 'email') return None
def require_email(backend, details, weblate_action, user=None, is_new=False, **kwargs): """Force entering e-mail for backends which don't provide it.""" if backend.name == "github": email = get_github_email(kwargs["response"]["access_token"]) if email is not None: details["email"] = email if details.get("email", "").endswith("@users.noreply.github.com"): del details["email"] # Remove any pending e-mail validation codes if details.get("email") and backend.name == "email": invalidate_reset_codes(emails=(details["email"], )) # Remove all account reset codes if user and weblate_action == "reset": invalidate_reset_codes(user=user) if user and user.email: # Force validation of new e-mail address if backend.name == "email": return {"is_new": True} return None if is_new and not details.get("email"): raise AuthMissingParameter(backend, "email") return None
def save(self, request, delete_session=False): notify_account_activity( self.user, request, 'password', password=self.user.password ) # Change the password password = self.cleaned_data["new_password1"] self.user.set_password(password) self.user.save(update_fields=['password']) if delete_session: request.session.flush() else: # Updating the password logs out all other sessions for the user # except the current one. update_session_auth_hash(request, self.user) # Change key for current session request.session.cycle_key() # Invalidate password reset codes invalidate_reset_codes(self.user) messages.success( request, _('Your password has been changed.') )
def adjust_primary_mail(strategy, entries, user, *args, **kwargs): """Fix primary mail on disconnect.""" # Remove pending verification codes invalidate_reset_codes(user=user, entries=entries) # Check remaining verified mails verified = VerifiedEmail.objects.filter( social__user=user, ).exclude( social__in=entries ) if verified.filter(email=user.email).exists(): return user.email = verified[0].email user.save() messages.warning( strategy.request, _( 'Your e-mail no longer belongs to verified account, ' 'it has been changed to {0}.' ).format( user.email ) )
def require_email(backend, details, weblate_action, user=None, is_new=False, **kwargs): """Force entering email for backends which don't provide it.""" if backend.name == 'github': email = get_github_email(kwargs['response']['access_token']) if email is not None: details['email'] = email # Remove any pending email validation codes if details.get('email') and backend.name == 'email': invalidate_reset_codes(emails=(details['email'],)) # Remove all account reset codes if user and weblate_action == 'reset': invalidate_reset_codes(user=user) if user and user.email: # Force validation of new email address if backend.name == 'email': return {'is_new': True} return None elif is_new and not details.get('email'): raise AuthMissingParameter(backend, 'email') return None
def adjust_primary_mail(strategy, entries, user, *args, **kwargs): """Fix primary mail on disconnect.""" # Remove pending verification codes invalidate_reset_codes(user=user, entries=entries) # Check remaining verified mails verified = VerifiedEmail.objects.filter( social__user=user, ).exclude( social__in=entries ) if verified.filter(email=user.email).exists(): return user.email = verified[0].email user.save() messages.warning( strategy.request, _( 'Your email no longer belongs to verified account, ' 'it has been changed to {0}.' ).format( user.email ) )
def save(self, request, delete_session=False): notify_account_activity( self.user, request, 'password', password=self.user.password ) # Change the password password = self.cleaned_data["new_password1"] self.user.set_password(password) self.user.save(update_fields=['password']) # Updating the password logs out all other sessions for the user # except the current one. update_session_auth_hash(request, self.user) # Change key for current session request.session.cycle_key() # Invalidate password reset codes invalidate_reset_codes(self.user) if delete_session: request.session.flush() messages.success( request, _('Your password has been changed.') )
def save(self, request, delete_session=False): AuditLog.objects.create( self.user, request, "password", password=self.user.password ) # Change the password password = self.cleaned_data["new_password1"] self.user.set_password(password) self.user.save(update_fields=["password"]) # Updating the password logs out all other sessions for the user # except the current one and change key for current session cycle_session_keys(request, self.user) # Invalidate password reset codes invalidate_reset_codes(self.user) if delete_session: request.session.flush() messages.success(request, _("Your password has been changed."))