Пример #1
0
def register(name, password, email):
    try:
        a = Account._by_name(name)
        raise AccountExists
    except NotFound:
        a = Account(name = name,
                    password = passhash(name, password, True))
        a.email = email

        a.confirmation_code = random_key(6)
        a.email_validated = False
        a.wiki_account = '__error__'

        a._commit()

        from r2.lib import emailer
        emailer.confirmation_email(a)

        if wiki_account.valid_name(name):
            def send_wiki_failed_email():
                emailer.wiki_failed_email(a)
            a.create_associated_wiki_account(password,
                                             on_request_error=send_wiki_failed_email)
        else:
            emailer.wiki_incompatible_name_email(a)

        # Clear memoization of both with and without deleted
        clear_memo('account._by_name', Account, name.lower(), True)
        clear_memo('account._by_name', Account, name.lower(), False)
        return a
Пример #2
0
def register(name, password, email, create_wiki_account=True):
    try:
        a = Account._by_name(name)
        raise AccountExists
    except NotFound:
        a = Account(name=name, password=passhash(name, password, True))
        a.email = email

        a.confirmation_code = random_key(6)
        a.email_validated = False
        a.wiki_account = '__error__'

        a._commit()

        from r2.lib import emailer
        emailer.confirmation_email(a)

        if create_wiki_account:
            if wiki_account.valid_name(name):

                def send_wiki_failed_email():
                    emailer.wiki_failed_email(a)

                a.create_associated_wiki_account(
                    password, on_request_error=send_wiki_failed_email)
            else:
                emailer.wiki_incompatible_name_email(a)

        # Clear memoization of both with and without deleted
        clear_memo('account._by_name', Account, name.lower(), True)
        clear_memo('account._by_name', Account, name.lower(), False)
        return a
Пример #3
0
def register(name, password, email, create_wiki_account=True):
    try:
        a = Account._by_name(name)
        raise AccountExists
    except NotFound:
        a = Account(name=name, password=passhash(name, password, True))
        a.email = email

        a.confirmation_code = random_key(6)
        a.email_validated = False

        a._commit()

        from r2.lib import emailer
        emailer.confirmation_email(a)

        # Clear memoization of both with and without deleted
        clear_memo('account._by_name', Account, name.lower(), True)
        clear_memo('account._by_name', Account, name.lower(), False)
        return a
Пример #4
0
def register(name, password, email, create_wiki_account=True):
    try:
        a = Account._by_name(name)
        raise AccountExists
    except NotFound:
        a = Account(name = name,
                    password = passhash(name, password, True))
        a.email = email

        a.confirmation_code = random_key(6)
        a.email_validated = False

        a._commit()

        from r2.lib import emailer
        emailer.confirmation_email(a)

        # Clear memoization of both with and without deleted
        clear_memo('account._by_name', Account, name.lower(), True)
        clear_memo('account._by_name', Account, name.lower(), False)
        return a