Beispiel #1
0
def password_email(user):
    key = passhash(random.randint(0, 1000), user.email)
    passlink = 'http://' + g.domain + '/resetpassword/' + key
    cache.set("reset_%s" %key, user._id, time=1800)
    simple_email(user.email, '*****@*****.**',
                 'lesswrong.com password reset',
                 PasswordReset(user=user, passlink=passlink).render(style='email'))
Beispiel #2
0
def password_email(user):
    """
    For resetting a user's password.
    """
    from r2.lib.pages import PasswordReset

    reset_count_key = "email-reset_count_%s" % user._id
    g.cache.add(reset_count_key, 0, time=3600 * 12)
    if g.cache.incr(reset_count_key) > 3:
        return False

    reset_count_global = "email-reset_count_global"
    g.cache.add(reset_count_global, 0, time=3600)
    if g.cache.incr(reset_count_global) > 1000:
        raise ValueError("Somebody's beating the hell out of the password reset box")

    key = passhash(randstr(64, reallyrandom = True), user.email)
    passlink = 'http://' + g.domain + '/resetpassword/' + key
    g.log.info("Generated password reset link: " + passlink)
    g.hardcache.set("email-reset_%s" % key, user._id, time=3600 * 12)
    _system_email(user.email,
                  PasswordReset(user=user,
                                passlink=passlink).render(style='email'),
                  Email.Kind.RESET_PASSWORD)
    return True
Beispiel #3
0
def password_email(user):
    key = passhash(random.randint(0, 1000), user.email)
    passlink = 'http://' + g.domain + '/resetpassword/' + key
    cache.set("reset_%s" % key, user._id, time=1800)
    simple_email(
        user.email, '*****@*****.**', 'lesswrong.com password reset',
        PasswordReset(user=user, passlink=passlink).render(style='email'))
Beispiel #4
0
def password_email(user):
    key = passhash(random.randint(0, 1000), user.email)
    passlink = 'http://' + g.domain + '/resetpassword/' + key
    cache.set("reset_%s" %key, user._id, time=1800)
    simple_email(user.email, '*****@*****.**',
                 '%s password reset' % g.front_page_title,
                 PasswordReset(user=user, passlink=passlink).render(style='email'))
Beispiel #5
0
def password_email(user):
    """
    For resetting a user's password.
    """
    from r2.lib.pages import PasswordReset

    reset_count_key = "email-reset_count_%s" % user._id
    g.cache.add(reset_count_key, 0, time=3600 * 12)
    if g.cache.incr(reset_count_key) > 3:
        return False

    reset_count_global = "email-reset_count_global"
    g.cache.add(reset_count_global, 0, time=3600)
    if g.cache.incr(reset_count_global) > 1000:
        raise ValueError(
            "Somebody's beating the hell out of the password reset box")

    key = passhash(randstr(64, reallyrandom=True), user.email)
    passlink = 'http://' + g.domain + '/resetpassword/' + key
    g.log.info("Generated password reset link: " + passlink)
    g.hardcache.set("email-reset_%s" % key, user._id, time=3600 * 12)
    _system_email(
        user.email,
        PasswordReset(user=user, passlink=passlink).render(style='email'),
        Email.Kind.RESET_PASSWORD)
    return True
Beispiel #6
0
def password_email(user):
    key = passhash(random.randint(0, 1000), user.email)
    passlink = 'http://' + g.domain + '/resetpassword/' + key
    cache.set("reset_%s" % key, user._id, time=1800)
    simple_email(
        user.email, '*****@*****.**',
        '%s password reset' % g.front_page_title,
        PasswordReset(user=user, passlink=passlink).render(style='email'))
Beispiel #7
0
def password_email(user):
    key = passhash(random.randint(0, 1000), user.email)
    passlink = 'http://' + g.domain + '/resetpassword/' + key
    print "Generated password reset link: " + passlink
    cache.set("reset_%s" %key, user._id, time=1800)
    simple_email(user.email, '*****@*****.**',
                 'reddit.com password reset',
                 PasswordReset(user=user, passlink=passlink).render(style='email'))
Beispiel #8
0
def password_email(user):
    key = passhash(random.randint(0, 1000), user.email)
    passlink = "http://" + g.domain + "/resetpassword/" + key
    cache.set("reset_%s" % key, user._id, time=1800)
    simple_email(
        user.email,
        "*****@*****.**",
        "%s password reset" % g.front_page_title,
        PasswordReset(user=user, passlink=passlink).render(style="email"),
    )
Beispiel #9
0
def password_email(user):
    """
    For resetting a user's password.
    """
    from r2.lib.pages import PasswordReset
    key = passhash(randstr(64, reallyrandom = True), user.email)
    passlink = 'http://' + g.domain + '/resetpassword/' + key
    print "Generated password reset link: " + passlink
    g.cache.set("reset_%s" %key, user._id, time=1800)
    _system_email(user.email,
                  PasswordReset(user=user,
                                passlink=passlink).render(style='email'),
                  Email.Kind.RESET_PASSWORD)
Beispiel #10
0
def password_email(user):
    """
    For resetting a user's password.
    """
    from r2.lib.pages import PasswordReset
    key = passhash(randstr(64, reallyrandom = True), user.email)
    passlink = 'http://' + g.domain + '/resetpassword/' + key
    print "Generated password reset link: " + passlink
    g.cache.set("reset_%s" %key, user._id, time=1800)
    _system_email(user.email,
                  PasswordReset(user=user,
                                passlink=passlink).render(style='email'),
                  Email.Kind.RESET_PASSWORD)
Beispiel #11
0
def verify_email(user, dest):
    """
    For verifying an email address
    """
    from r2.lib.pages import VerifyEmail
    key = passhash(user.name, user.email)
    user.email_verified = False
    user._commit()
    emaillink = ('http://' + g.domain + '/verification/' + key
                 + query_string(dict(dest=dest)))
    print "Generated email verification link: " + emaillink
    g.cache.set("email_verify_%s" %key, user._id, time=1800)

    _system_email(user.email,
                  VerifyEmail(user=user,
                              emaillink = emaillink).render(style='email'),
                  Email.Kind.VERIFY_EMAIL)
Beispiel #12
0
def verify_email(user, dest):
    """
    For verifying an email address
    """
    from r2.lib.pages import VerifyEmail
    key = passhash(user.name, user.email)
    user.email_verified = False
    user._commit()
    Award.take_away("verified_email", user)
    emaillink = ('http://' + g.domain + '/verification/' + key
                 + query_string(dict(dest=dest)))
    g.log.debug("Generated email verification link: " + emaillink)
    g.cache.set("email_verify_%s" %key, user._id, time=1800)

    _system_email(user.email,
                  VerifyEmail(user=user,
                              emaillink = emaillink).render(style='email'),
                  Email.Kind.VERIFY_EMAIL)