def findTemporaryEmailCredential(self, secret): cred = Credential.getBySecret("changeemail", secret) verify = False if cred is None: credverify = Credential.getBySecret("changeemailandverify", secret) if credverify is None: raise ReportedError(badChangeEmailSecret, 403) else: cred = credverify verify = True return cred, verify
def the_reset_link_is_in_the_reset_email(self): self._sendPasswordResetEmail() text = self.outbox[0].html soup = BeautifulSoup(text, "lxml") passwordResetLink = soup.find("a")['href'] self.secret = passwordResetLink.split('secret=')[1] self.tempcred = Credential.getBySecret('email_for_password_reset',self.secret) return passwordResetLink
def the_reset_link_is_in_the_reset_email(self): self._sendPasswordResetEmail() text = self.outbox[0].html soup = BeautifulSoup(text, "lxml") passwordResetLink = soup.find("a")['href'] self.secret = passwordResetLink.split('secret=')[1] self.tempcred = Credential.getBySecret('email_for_password_reset', self.secret) return passwordResetLink
def doDeregistrationDoit(self, form): Credential.deleteExpired('deregister') secret = form.deregister_secret.data if secret is None: raise ReportedError( [secretIsNeededForDeregistrationDoit],400) deregistrationCredential = Credential.getBySecret('deregister', secret) if deregistrationCredential is None: raise ReportedError([badDeregistrationSecret],400) user = deregistrationCredential.user self.removeUser(user) return self.simple_response(youAreDeregistered)
def doPasswordReset(self, form): Credential.deleteExpired(self.passwordResetCredentialType) cred = Credential.getBySecret( self.passwordResetCredentialType, form.secret.data) if cred is None or (cred.getExpirationTime() < time.time()): raise ReportedError([theSecretHasExpired], 404) passcred = Credential.getByUser(cred.user, 'password') protectedSecret = CredentialManager.protect_secret(form.password.data) if not passcred: passcred = Credential.new(cred.user, "password", cred.user.email, protectedSecret) else: passcred.secret = protectedSecret cred.rm() return self.simple_response(passwordSuccessfullyChanged)
def getCredentialForEmailverifyToken(self, token): cred = Credential.getBySecret('emailcheck', token) return cred