• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python Credential.Credential类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pdoauth.models.Credential.Credential的典型用法代码示例。如果您正苦于以下问题:Python Credential类的具体用法?Python Credential怎么用?Python Credential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Credential类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_timed_out_emailcheck_credentials_are_cleared_in_registration

 def test_timed_out_emailcheck_credentials_are_cleared_in_registration(self):
     for someone in User.query.all()[:5]:  # @UndefinedVariable
         Credential.new(someone, 'emailcheck', str(time.time()-1)+":"+uuid4().hex, uuid4().hex)
     self.assertTrue(self.countExpiredCreds('emailcheck')>=5)
     form = self.prepareLoginForm()
     self.controller.doRegistration(form)
     self.assertTrue(self.countExpiredCreds('emailcheck')==0)
开发者ID:Claymanus,项目名称:PDOauth,代码行数:7,代码来源:RegistrationTest.py


示例2: you_can_login_using_facebook

 def you_can_login_using_facebook(self):
     if config.skipFacebookTests:
         return
     self.user = self.createUserWithCredentials("facebook", config.fbuserid, None, config.fbuser)
     self.user.activate()
     driver = self.driver
     driver.get(self.base_url+"/static/login.html")
     self.switchToTab("login")
     driver.find_element_by_id("Facebook_login_button").click()
     time.sleep(1)
     self._switchWindow(driver)
     driver.find_element_by_id("pass").clear()
     driver.find_element_by_id("pass").send_keys(config.fbpassword)
     driver.find_element_by_id("email").clear()
     driver.find_element_by_id("email").send_keys(config.fbuser)
     driver.find_element_by_id("u_0_2").click()
     driver.switch_to.window(self.master)
     time.sleep(1)
     self.assertEqual(self.base_url  + "/static/login.html", driver.current_url)
     body = driver.find_element_by_id("message").text
     self.assertEqual("", body)
     body = driver.find_element_by_id("userdata").text
     self.assertTrue("[email protected]"in body)
     Credential.getByUser(self.user, "facebook").rm()
     self.user.rm()
开发者ID:Sinnach0,项目名称:PDOauth,代码行数:25,代码来源:facebook.py


示例3: unregistered_user_can_register_with_facebook_in_the_middle_of_login_procedure_of_a_served_application

 def unregistered_user_can_register_with_facebook_in_the_middle_of_login_procedure_of_a_served_application(self):
     if config.skipFacebookTests:
         return
     driver = self.driver
     self._gotoOauthPage(driver)
     self.switchToTab('registration')
     driver.find_element_by_id("Facebook_registration_button").click()
     time.sleep(1)
     self.master = driver.current_window_handle
     timeCount = 1;
     while (len(driver.window_handles) == 1 ):
         time
         timeCount += 1
         if ( timeCount > 50 ): 
             break;
     for handle in driver.window_handles:
         if handle!=self.master:
             driver.switch_to.window(handle)
     driver.find_element_by_id("pass").clear()
     driver.find_element_by_id("pass").send_keys(config.fbpassword2)
     driver.find_element_by_id("email").clear()
     driver.find_element_by_id("email").send_keys(config.fbuser2)
     driver.find_element_by_id("u_0_2").click()
     driver.switch_to.window(self.master)
     time.sleep(5)
     self.assertTrue(driver.current_url.startswith(self.redirect_uri.lower()))
     self.user = User.getByEmail(config.fbuser2)
     Credential.getByUser(self.user, "facebook").rm()
     self.user.rm()
开发者ID:Sinnach0,项目名称:PDOauth,代码行数:29,代码来源:new_user.py


示例4: do_add_credential

 def do_add_credential(self, form):
     user = self.getCurrentUser()
     Credential.new(user,
         form.credentialType.data,
         form.identifier.data,
         form.secret.data)
     return self.as_dict(user)
开发者ID:Sinnach0,项目名称:PDOauth,代码行数:7,代码来源:Controller.py


示例5: sendPasswordVerificationEmail

 def sendPasswordVerificationEmail(self, user):
     secret=unicode(uuid4())
     expiry = time.time() + 60*60*24*4
     Credential.new(user, 'emailcheck', unicode(expiry), secret )
     timeText = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(expiry))
     uri = "{0}/v1/verify_email/{1}".format(self.getConfig('BASE_URL'),secret)
     text = """Hi, click on <a href="{0}">{0}</a> until {1} to verify your email""".format(uri, timeText)
     self.mail.send_message(subject="verification", body=text, recipients=[user.email], sender=self.getConfig('SERVER_EMAIL_ADDRESS'))
开发者ID:Sinnach0,项目名称:PDOauth,代码行数:8,代码来源:EmailHandling.py


示例6: test_the_credential_is_actually_added

 def test_the_credential_is_actually_added(self):
     myUserid = self.createRandomUserId()
     credBefore = Credential.get("password", myUserid)
     self.assertTrue(credBefore is None)
     resp = self._createPasswordCredential(userid=myUserid)
     self.assertEqual(200, resp.status_code)
     credAfter = Credential.get("password", myUserid)
     self.assertTrue(credAfter is not None)
开发者ID:Claymanus,项目名称:PDOauth,代码行数:8,代码来源:CredentialTest.py


示例7: doConfirmChangeEmail

 def doConfirmChangeEmail(self, secret=None, confirm=True, useverifysecret=False):
     self.controller.emailChangeInit(self.newEmailAddress, self.user)
     if secret is None:
         if useverifysecret:
             secret = Credential.getByUser(self.user, 'changeemailandverify').secret
         else:
             secret = Credential.getByUser(self.user, 'changeemail').secret
     return self.controller.confirmEmailChange(FakeForm(dict(confirm=confirm, secret=secret)))
开发者ID:edemo,项目名称:PDOauth,代码行数:8,代码来源:EmailUtil.py


示例8: test_password_reset_creates_password_if_it_does_not_exists

 def test_password_reset_creates_password_if_it_does_not_exists(self):
     form = self.createPasswordResetFormWithSecret()
     user = User.getByEmail(self.userCreationEmail)
     passcred = Credential.getByUser(user, "password")
     passcred.rm()
     self.controller.doPasswordReset(form)
     newPassCred = Credential.getByUser(user, "password")
     self.assertEqual(newPassCred.secret, CredentialManager.protect_secret(self.newPassword))
开发者ID:edemo,项目名称:PDOauth,代码行数:8,代码来源:PasswordResetTest.py


示例9: _removeACredential

 def _removeACredential(self, myUserid):
     self.controller.loginInFramework(self.cred)
     user = self.cred.user
     Credential.new(user, "facebook", myUserid, "testsecret")
     data = {"credentialType": "facebook",
         "identifier": myUserid}
     self.assertTrue(Credential.get("facebook", myUserid))
     resp = self.controller.doRemoveCredential(FakeForm(data))
     return resp
开发者ID:Claymanus,项目名称:PDOauth,代码行数:9,代码来源:CredentialTest.py


示例10: emailChangeInit

 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")
开发者ID:Claymanus,项目名称:PDOauth,代码行数:9,代码来源:EmailHandling.py


示例11: do_password_reset

 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')
开发者ID:Sinnach0,项目名称:PDOauth,代码行数:9,代码来源:Controller.py


示例12: removeFbuser

 def removeFbuser(self,user=None):
     if user is None:
         user = config.facebookUser2
     self.user = User.getByEmail(user.email)
     if self.user:
         Credential.getByUser(self.user, "facebook").rm()
         for appMap in AppMap.getForUser(self.user):
             appMap.rm()
         self.user.rm()
开发者ID:edemo,项目名称:PDOauth,代码行数:9,代码来源:FacebookUtil.py


示例13: no_password_reset_for_timed_out_temporary_credential

 def no_password_reset_for_timed_out_temporary_credential(self):
     password = self.mkRandomPassword()
     secret = unicode(uuid4())
     user = User.getByEmail(self.usercreation_email)
     Credential.new(user, 'email_for_password_reset', secret, time.time()-1)
     with app.test_client() as c:
         data = dict(password=password, secret=secret)
         resp = c.post("/v1/password_reset", data = data)
         self.assertEqual(resp.status_code, 404)
开发者ID:Sinnach0,项目名称:PDOauth,代码行数:9,代码来源:PasswordResetTest.py


示例14: successful_password_clears_the_temporary_credential

 def successful_password_clears_the_temporary_credential(self):
     password = self.mkRandomPassword()
     secret = unicode(uuid4())
     user = User.getByEmail(self.usercreation_email)
     Credential.new(user, 'email_for_password_reset', secret, time.time()+3600)
     with app.test_client() as c:
         data = dict(password=password, secret=secret)
         c.post("/v1/password_reset", data = data)
         newcred = Credential.get('email_for_password_reset', secret)
         self.assertEquals(newcred, None)
开发者ID:Sinnach0,项目名称:PDOauth,代码行数:10,代码来源:PasswordResetTest.py


示例15: successful_password_reset_sets_the_password

 def successful_password_reset_sets_the_password(self):
     password = self.mkRandomPassword()
     secret = unicode(uuid4())
     user = User.getByEmail(self.usercreation_email)
     Credential.new(user, 'email_for_password_reset', secret, time.time()+3600)
     with app.test_client() as c:
         data = dict(password=password, secret=secret)
         c.post("/v1/password_reset", data = data)
         cred = Credential.getByUser(user, "password")
         self.assertEquals(cred.secret, CredentialManager.protect_secret(password))
开发者ID:Sinnach0,项目名称:PDOauth,代码行数:10,代码来源:PasswordResetTest.py


示例16: test_bad_secret_clears_up_all_timed_out_temporary_credentials

 def test_bad_secret_clears_up_all_timed_out_temporary_credentials(self):
     password = self.mkRandomPassword()
     secret = uuid4().hex
     for someone in User.query.all()[:5]:  # @UndefinedVariable
         Credential.new(someone, 'email_for_password_reset', str(time.time()-1)+":"+uuid4().hex, uuid4().hex)
     self.assertTrue(self.countExpiredCreds()>=5)
     data = dict(password=password, secret=secret)
     self.assertReportedError(self.controller.doPasswordReset,(FakeForm(data),),
             404, ['The secret has expired'])
     self.assertEqual(self.countExpiredCreds(),0)
开发者ID:edemo,项目名称:PDOauth,代码行数:10,代码来源:PasswordResetTest.py


示例17: test_the_credential_used_for_login_cannot_be_cleared

 def test_the_credential_used_for_login_cannot_be_cleared(self):
     credential = self.createUserWithCredentials()
     self.controller.loginInFramework(credential)
     self.assertTrue(Credential.get("password", self.userCreationUserid))
     form = FakeForm({
         "identifier": self.userCreationUserid,
         "credentialType": "password",
     })
     self.assertReportedError(self.controller.doRemoveCredential,[form], 400, ["You cannot delete the login you are using"])
     self.assertTrue(Credential.get("password", self.userCreationUserid))
开发者ID:Claymanus,项目名称:PDOauth,代码行数:10,代码来源:CredentialTest.py


示例18: do_send_password_reset_email

 def do_send_password_reset_email(self, email):
     user = User.getByEmail(email)
     if user is None:
         raise ReportedError(['Invalid email address'])
     passwordResetEmailExpiration = 14400
     secret=unicode(uuid4())
     expirationTime = time.time() + passwordResetEmailExpiration
     Credential.new(user, passwordResetCredentialType, secret, unicode(expirationTime))
     self.sendPasswordResetMail(user, secret, expirationTime)
     return self.simple_response("Password reset email has successfully sent.")
开发者ID:Sinnach0,项目名称:PDOauth,代码行数:10,代码来源:Controller.py


示例19: findTemporaryEmailCredential

 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
开发者ID:Claymanus,项目名称:PDOauth,代码行数:11,代码来源:EmailHandling.py


示例20: test_valid_secret_is_accepted

 def test_valid_secret_is_accepted(self):
     password = self.mkRandomPassword()
     secret = uuid4().hex
     user = User.getByEmail(self.userCreationEmail)
     Credential.new(user, 'email_for_password_reset', str(time.time()+3600), secret)
     with app.test_client() as client:
         data = dict(password=password, secret=secret)
         resp = client.post("/v1/password_reset", data = data)
         self.assertEqual(resp.status_code, 200)
         respData = self.fromJson(resp)
         self.assertEqual("Password successfully changed",respData['message'])
开发者ID:Claymanus,项目名称:PDOauth,代码行数:11,代码来源:PasswordResetIntegrationTest.py



注:本文中的pdoauth.models.Credential.Credential类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python dataobj.DataObject类代码示例发布时间:2022-05-27
下一篇:
Python android_distribution.AndroidDistribution类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap