예제 #1
0
    def verify_email(self, mail_manager, request):
        mail = mail_manager.helper()
        sign = Sign()

        token = sign.sign('{0}::{1}'.format(self.id, time.time()))
        link = '{0}/email/verify/{1}'.format(request.environ['HTTP_HOST'], token)

        mail.to(self.email) \
            .template('auth/verifymail', {'name': self.name, 'email': self.email, 'link': link}) \
            .subject('Please Confirm Your Email').send()
예제 #2
0
    def verify_email(self, mail_manager, request):
        """Sends email for user verification

        Arguments:
            mail_manager {masonite.managers.MailManager} -- Masonite mail manager class.
            request {masonite.request.Request} -- Masonite request class.
        """
        mail = mail_manager.helper()
        sign = Sign()

        token = sign.sign('{0}::{1}'.format(self.id, time.time()))
        link = '{0}/email/verify/{1}'.format(request.environ['HTTP_HOST'],
                                             token)

        mail.to(self.email) \
            .template('auth/verifymail', {'name': self.name, 'email': self.email, 'link': link}) \
            .subject('Please Confirm Your Email').send()
예제 #3
0
    def verify_email(self, mail_manager, request):
        """Sends email for user verification

        Arguments:
            mail_manager {masonite.managers.MailManager} -- Masonite mail manager class.
            request {masonite.request.Request} -- Masonite request class.
        """
        mail = mail_manager.helper()
        sign = Sign()

        token = sign.sign("{0}::{1}".format(self.id, time.time()))
        link = "{0}/users/verify-email/{1}".format(
            request.environ["HTTP_HOST"], token)

        mail.to(self.email).template(
            "users/email-verification-email",
            {
                "name": self.name,
                "email": self.email,
                "link": link
            },
        ).subject("{0}: Confirm Your Email".format(
            config("application.name"))).send()
예제 #4
0
 def test_unsigning_without_value(self):
     s = Sign(self.secret_key)
     s.sign('value')
     assert s.unsign() == 'value'
예제 #5
0
 def test_unsigning_returns_decrypted_value_without_parameter(self):
     s = Sign(self.secret_key)
     assert s.unsign(s.sign('value')) == 'value'
 def test_sign_incorrect_padding(self):
     with pytest.raises(InvalidSecretKey):
         padded_secret_key = "AQAAQDhAAMAAQYS04MjQ2LWRkYzJkMmViYjQ2YQ==="
         s = Sign(padded_secret_key)
         assert s.sign('value')
예제 #7
0
def test_unsigning_returns_decrypted_value_with_parameter():
    s = Sign(SECRET_KEY)
    assert s.unsign(s.sign('value')) == 'value'
예제 #8
0
def test_unsigning_without_value():
    s = Sign(SECRET_KEY)
    s.sign('value')
    assert s.unsign() == 'value'