コード例 #1
0
ファイル: Splitpot.py プロジェクト: Jupiterrr/splitpot
    def doAddAlias(self, alias=None, mainMail=None, key=None):
        """
        Add an alias to this account.
        """

        tmpl = lookup.get_template("alias.html")
        errors = ""

        if key is not None and isValidMergeUrlKey(key):
            mainMail = getUserFromPassword(key[:8])
            alias = getUserFromPassword(key[8:])

            log.info('valid alias key, add "' + alias + '" as alias to "' + mainMail)

            if mergeUser(mainMail, alias):
                addAlias(mainMail, alias)
                return tmpl.render(good_news="Your alias has been added")
            else:
                log.warning("couldn't alias/merge \"" + newUser + '" and "' + oldUser + '" for some unexpected reason')
                return tmpl.render(
                    bad_news="Oh no! Something went wrong. Please try again later.", newUser=getCurrentUserName()
                )
        elif alias is not None:
            log.info("alias is not not")

            alias = [x.strip() for x in alias.split(",")]
            for user in alias:
                if emailRegex.match(user) == None:
                    errors += "<li>" + user + " is invalid</li>"
                else:

                    if userExists(user, True):
                        errors += (
                            "<li>" + user + ' already exists, use <a href="../merge">Merge E-Mails</a> instead</li>'
                        )
                    elif aliasUserExists(user):
                        errors += "<li>" + user + " is already an alias for someone else</li>"

            if not errors == "":
                return tmpl.render(bad_news="<ul>" + errors + "</ul>")
            else:

                info = ""
                for user in alias:
                    if activateUser(user, "Alias for " + user, "random", True):
                        log.info("register " + user + " for the purpose of adding as alias")
                        aliasKey = getMergeUrlKey(getCurrentUserName(), user)

                        Email.aliasRequest(getCurrentUserName(), user, aliasKey)
                        info += '<li>An email has been sent to "' + user.lower() + '" for further information</li>'

                return tmpl.render(good_news=info)
        else:

            return tmpl.render(good_news="Nothing to add to aliases list")
コード例 #2
0
ファイル: User.py プロジェクト: toebbel/splitpot
def doAddAlias(alias=None, mainMail=None, key=None):
    """
    Add an alias to this account.
    """

    tmpl = lookup.get_template('profile.html')
    errors = ''

    if key is not None and isValidAliasUrlKey(key):
        mainMail = getUserFromPassword(key[:8])
        alias = getUserFromPassword(key[8:])

        log.info('valid alias key, add "' + alias + '" as alias to "'
                 + mainMail)

        if mergeUser(mainMail, alias):
            return tmpl.render(good_news='Your alias has been added')
        else:
            log.warning('couldn\'t alias/merge "' + currentUser
                        + '" and "' + oldUser
                        + '" for some unexpected reason')
            return tmpl.render(bad_news='Oh no! Something went wrong. Please try again later.'
                               )
    elif alias is not None:
        log.info('alias is not not')

        alias = [x.strip() for x in alias.split(',')]
        for user in alias:
            if emailRegex.match(user) == None:
                errors += '<li>' + user + ' is invalid</li>'
            else:

                if userExists(user, True):
                    errors += '<li>' + user \
                        + ' already exists, use <a href="../merge">Merge E-Mails</a> instead</li>'
                elif aliasUserExists(user):
                    errors += '<li>' + user \
                        + ' is already an alias for someone else</li>'

        if not errors == '':
            return tmpl.render(bad_news='<ul>' + errors + '</ul>')
        else:

            info = ''
            for user in alias:
                if activateUser(user, 'Alias for ' + user, 'random',
                                True):
                    log.info('register ' + user
                             + ' for the purpose of adding as alias')
                    aliasKey = getMergeUrlKey(getCurrentUserName(),
                            user)

                    Email.aliasRequest(getCurrentUserName(), user,
                            aliasKey)
                    info += '<li>An email has been sent to "' \
                        + user.lower() \
                        + '" for further information</li>'

            return tmpl.render(good_news=info)
    else:

        return tmpl.render(good_news='Nothing to add to aliases list')