Ejemplo n.º 1
0
 def make_api_key(self):
     secret_data = {
         'userId': self.id,
         'action': 'api_key',
     }
     secret = Secret.create_secret(info=secret_data, hours_duration=24)
     return secret
Ejemplo n.º 2
0
def request_signup_email_confirmation(user):
    secret_info = {
        'userId': user.id,
        'email': user.email,
        'action': 'email_confirmation',
    }
    hours_duration = 48
    secret = Secret.create_secret(secret_info, hours_duration)
    content = '''A community share account has been created and attached to this email address.

To confirm that you created the account, please click on the following link.

{BASEURL}/#/confirmemail?key={secret_key}

If you did not create this account, simply ignore this email.
'''
    content = content.format(BASEURL=config.BASEURL, secret_key=secret.key)
    email = mail.Email(
        from_address=config.DONOTREPLY_EMAIL_ADDRESS,
        to_address=user.email,
        subject='CommunityShare Account Creation',
        content=content,
        new_content=content
    )
    error_message = mail.get_mailer().send(email)
    return error_message
Ejemplo n.º 3
0
def request_password_reset(user):
    secret_info = {
        'userId': user.id,
        'action': 'password_reset',
    }
    hours_duration = 48
    secret = Secret.create_secret(secret_info, hours_duration)
    content = '''We received a request to reset your password for CommunityShare.
    
To reset your password please click on the following link and follow the instructions.
    
{BASEURL}/#/resetpassword?key={secret_key}
    
If you cannot click on the link copy it into the addressbar of your browser.
'''
    content = content.format(BASEURL=config.BASEURL, secret_key=secret.key)
    if not user.email_confirmed:
        error_message = 'The email address is not confirmed.'
    else:
        email = mail.Email(
            from_address=config.DONOTREPLY_EMAIL_ADDRESS,
            to_address=user.confirmed_email,
            subject='CommunityShare Password Reset Request',
            content=content,
            new_content=content,
        )
        error_message = mail.get_mailer().send(email)
    return error_message
Ejemplo n.º 4
0
 def make_api_key(self):
     secret_data = {
         'userId': self.id,
         'action': 'api_key',
     }
     secret = Secret.create_secret(info=secret_data, hours_duration=24)
     return secret
Ejemplo n.º 5
0
def request_password_reset(user):
    secret_info = {
        'userId': user.id,
        'action': 'password_reset',
    }
    hours_duration = 48
    secret = Secret.create_secret(secret_info, hours_duration)
    url = '{BASEURL}/#/resetpassword?key={secret_key}'.format(
        BASEURL=config.BASEURL, secret_key=secret.key)
    content = '''<p>We received a request to reset your password for CommunityShare.</p>
    
<p>To reset your password please click on the following link and follow the instructions.</p>
    
<a href={url}>{url}</a>
    
<p>If you cannot click on the link copy it into the addressbar of your browser.</p>
'''
    content = content.format(url=url)
    email = mail.Email(
        from_address=config.DONOTREPLY_EMAIL_ADDRESS,
        to_address=user.email,
        subject='CommunityShare Password Reset Request',
        content=content,
        new_content=content,
        )
    error_message = mail.get_mailer().send(email)
    return error_message
Ejemplo n.º 6
0
def request_signup_email_confirmation(user, template=None, subject=None):
    secret_info = {
        'userId': user.id,
        'email': user.email,
        'action': 'email_confirmation',
    }
    hours_duration = 24*14
    secret = Secret.create_secret(secret_info, hours_duration)
    url = '{BASEURL}/#/confirmemail?key={secret_key}'.format(
        BASEURL=config.BASEURL, secret_key=secret.key)
    if template is None:
        template = '''<p>A community share account has been created and attached to this email address.<p>

        <p>To confirm that you created the account, please click on the following link.</p>

        <p><a href={url}>{url}</a></p>

        <p>If you did not create this account, simply ignore this email.</p>
'''
    content = template.format(url=url)
    if subject is None:
        subject = 'CommunityShare Account Creation'
    email = mail.Email(
        from_address=config.DONOTREPLY_EMAIL_ADDRESS,
        to_address=user.email,
        subject=subject,
        content=content,
        new_content=content
    )
    error_message = mail.get_mailer().send(email)
    return error_message
Ejemplo n.º 7
0
def request_password_reset(user):
    secret_info = {
        'userId': user.id,
        'action': 'password_reset',
    }
    hours_duration = 48
    secret = Secret.create_secret(secret_info, hours_duration)
    url = '{BASEURL}/#/resetpassword?key={secret_key}'.format(
        BASEURL=config.BASEURL,
        secret_key=secret.key,
    )
    content = '''<p>We received a request to reset your password for CommunityShare.</p>
    
<p>To reset your password please click on the following link and follow the instructions.</p>
    
<a href={url}>{url}</a>
    
<p>If you cannot click on the link copy it into the addressbar of your browser.</p>
'''
    content = content.format(url=url)
    email = mail.Email(
        from_address=config.DONOTREPLY_EMAIL_ADDRESS,
        to_address=user.email,
        subject='CommunityShare Password Reset Request',
        content=content,
        new_content=content,
    )
    error_message = mail.get_mailer().send(email)
    return error_message
Ejemplo n.º 8
0
def request_signup_email_confirmation(user, template=None, subject=None):
    secret_info = {
        'userId': user.id,
        'email': user.email,
        'action': 'email_confirmation',
    }
    hours_duration = 24 * 14
    secret = Secret.create_secret(secret_info, hours_duration)
    url = '{BASEURL}/#/confirmemail?key={secret_key}'.format(
        BASEURL=config.BASEURL,
        secret_key=secret.key,
    )
    if template is None:
        template = '''<p>A community share account has been created and attached to this email address.<p>

        <p>To confirm that you created the account, please click on the following link.</p>

        <p><a href={url}>{url}</a></p>

        <p>If you did not create this account, simply ignore this email.</p>
'''
    content = template.format(url=url)
    if subject is None:
        subject = 'CommunityShare Account Creation'
    email = mail.Email(from_address=config.DONOTREPLY_EMAIL_ADDRESS,
                       to_address=user.email,
                       subject=subject,
                       content=content,
                       new_content=content)
    error_message = mail.get_mailer().send(email)
    return error_message