Example #1
0
 def emailChangeInit(self, newEmailAddress, user):
     if User.getByEmail(newEmailAddress):
         raise ReportedError(thereIsAlreadyAUserWithThatEmail, 418)
     secret, expiry = CredentialManager.createTemporaryCredential(user, "changeemail",additionalInfo=newEmailAddress )
     self.sendEmail(user, secret, expiry, "CHANGE_EMAIL_OLD", newemail=newEmailAddress, oldemail=user.email )
     secret, expiry = CredentialManager.createTemporaryCredential(user, "changeemailandverify",additionalInfo=newEmailAddress )
     self.sendEmail(user, secret, expiry, "CHANGE_EMAIL_NEW", recipient=newEmailAddress, newemail=newEmailAddress, oldemail=user.email)
     Credential.deleteExpired("changeemail")
     Credential.deleteExpired("changeemailandverify")
Example #2
0
 def do_password_reset(self, form):
     cred = Credential.get(passwordResetCredentialType, form.secret.data)
     if cred is None or (float(cred.secret) < time.time()):
         Credential.deleteExpired(passwordResetCredentialType)
         raise ReportedError(['The secret has expired'], 404)
     passcred = Credential.getByUser(cred.user, 'password')
     passcred.secret = CredentialManager.protect_secret(form.password.data)
     cred.rm()
     return self.simple_response('Password successfully changed')
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 def doRegistration(self, form):
     Credential.deleteExpired('emailcheck')
     cred = CredentialManager.create_user_with_creds(
         form.credentialType.data,
         form.identifier.data,
         form.password.data,
         form.email.data,
         None)
     user = cred.user
     additionalInfo = self.checkAndUpdateHash(form, user)
     self.sendPasswordVerificationEmail(user)
     user.set_authenticated()
     user.activate()
     success = self.loginInFramework(cred)
     if success:
         return self.returnUserAndLoginCookie(user, additionalInfo)
Example #8
0
 def doRegistration(self, form):
     Credential.deleteExpired('emailcheck')
     cred = CredentialManager.create_user_with_creds(
         form.credentialType.data,
         form.identifier.data,
         form.password.data,
         form.email.data,
         None)
     user = cred.user
     additionalInfo = self.checkAndUpdateHash(form, user)
     self.sendPasswordVerificationEmail(user)
     user.set_authenticated()
     user.activate()
     success = self.loginInFramework(cred)
     if success:
         return self.returnUserAndLoginCookie(user, additionalInfo)
Example #9
0
 def emailChangeInit(self, newEmailAddress, user):
     if User.getByEmail(newEmailAddress):
         raise ReportedError(thereIsAlreadyAUserWithThatEmail, 418)
     secret, expiry = CredentialManager.createTemporaryCredential(
         user, "changeemail", additionalInfo=newEmailAddress)
     self.sendEmail(user,
                    secret,
                    expiry,
                    "CHANGE_EMAIL_OLD",
                    newemail=newEmailAddress,
                    oldemail=user.email)
     secret, expiry = CredentialManager.createTemporaryCredential(
         user, "changeemailandverify", additionalInfo=newEmailAddress)
     self.sendEmail(user,
                    secret,
                    expiry,
                    "CHANGE_EMAIL_NEW",
                    recipient=newEmailAddress,
                    newemail=newEmailAddress,
                    oldemail=user.email)
     Credential.deleteExpired("changeemail")
     Credential.deleteExpired("changeemailandverify")