Exemplo n.º 1
0
    def POST(self, profile_type, mail):
        i = web.input(
            enabledService=[],
            #mailForwardingAddress=[],
            shadowAddress=[],
            telephoneNumber=[],
            memberOfGroup=[],
            oldMemberOfAlias=[],
            memberOfAlias=[],
            #whitelistSender=[],
            #blacklistSender=[],
            #whitelistRecipient=[],
            #blacklistRecipient=[],
        )
        self.profile_type = web.safestr(profile_type)
        self.mail = str(mail).lower()

        userLib = userlib.User()
        result = userLib.update(
            profile_type=self.profile_type,
            mail=self.mail,
            data=i,
        )

        if result[0] is True:
            raise web.seeother('/profile/user/%s/%s?msg=UPDATED' %
                               (self.profile_type, self.mail))
        else:
            raise web.seeother(
                '/profile/user/%s/%s?msg=%s' %
                (self.profile_type, self.mail, web.urlquote(result[1])))
Exemplo n.º 2
0
    def POST(self, domain):
        i = web.input()

        # Get domain name, username, cn.
        self.username = web.safestr(i.get('username', ''))
        self.cur_domain = web.safestr(i.get('domainName', ''))

        userLib = userlib.User()
        result = userLib.add(domain=self.cur_domain, data=i)
        if result[0] is True:
            raise web.seeother('/profile/user/general/%s@%s?msg=CREATED' %
                               (self.username, self.cur_domain))
        else:
            raise web.seeother('/create/user/%s?msg=%s' %
                               (self.cur_domain, web.urlquote(result[1])))
Exemplo n.º 3
0
    def POST(self, domain):
        i = web.input(_unicode=False, mail=[])
        self.domain = web.safestr(domain)

        self.mails = [
            str(v) for v in i.get('mail', [])
            if iredutils.isEmail(v) and str(v).endswith('@' + self.domain)
        ]

        self.action = i.get('action', None)
        msg = i.get('msg', None)

        userLib = userlib.User()

        if self.action == 'delete':
            result = userLib.delete(
                domain=self.domain,
                mails=self.mails,
            )
            msg = 'DELETED'
        elif self.action == 'disable':
            result = userLib.enableOrDisableAccount(
                domain=self.domain,
                accounts=self.mails,
                active=False,
            )
            msg = 'DISABLED'
        elif self.action == 'enable':
            result = userLib.enableOrDisableAccount(
                domain=self.domain,
                accounts=self.mails,
                active=True,
            )
            msg = 'ENABLED'
        else:
            result = (False, 'INVALID_ACTION')

        if result[0] is True:
            raise web.seeother('/users/%s?msg=%s' % (
                self.domain,
                msg,
            ))
        else:
            raise web.seeother('/users/%s?msg=%s' % (
                self.domain,
                web.urlquote(result[1]),
            ))
Exemplo n.º 4
0
    def GET(self, domain, cur_page=1):
        self.domain = web.safestr(domain).split('/', 1)[0]
        cur_page = int(cur_page) or 1

        userLib = userlib.User()
        result = userLib.listAccounts(
            domain=self.domain,
            cur_page=cur_page,
        )
        if result[0] is True:
            (total, records) = (result[1], result[2])

            return web.render(
                'dbmail_mysql/user/list.html',
                cur_domain=self.domain,
                cur_page=cur_page,
                total=total,
                users=records,
                msg=web.input().get('msg', None),
            )
        else:
            raise web.seeother('/domains?msg=%s' % web.urlquote(result[1]))
Exemplo n.º 5
0
    def GET(self, profile_type, mail):
        i = web.input()
        self.mail = str(mail).lower()
        self.cur_domain = self.mail.split('@', 1)[-1]
        self.profile_type = str(profile_type)

        # profile_type == 'throttle'
        throttleOfSender = {}
        throttleOfRecipient = {}

        if self.mail.startswith('@') and iredutils.isDomain(self.cur_domain):
            # Catchall account.
            raise web.seeother('/profile/domain/catchall/%s' %
                               (self.cur_domain))

        if not iredutils.isEmail(self.mail):
            raise web.seeother('/domains?msg=INVALID_USER')

        if not iredutils.isDomain(self.cur_domain):
            raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')

        userLib = userlib.User()
        qr = userLib.profile(domain=self.cur_domain, mail=self.mail)
        if qr[0] is True:
            self.profile = qr[1]
        else:
            raise web.seeother('/users/%s?msg=%s' %
                               (self.cur_domain, web.urlquote(qr[1])))
        del qr

        # Get mail alias addresses.
        qr = userLib.getUserAliasAddresses(domain=self.cur_domain,
                                           mail=self.mail)
        if qr[0] is True:
            self.userAliasAddresses = qr[1]
        else:
            raise web.seeother('/users/%s?msg=%s' %
                               (self.cur_domain, web.urlquote(qr[1])))
        del qr

        # Get mail forwarding addresses.
        qr = userLib.getMailForwardingAddresses(domain=self.cur_domain,
                                                mail=self.mail)
        if qr[0] is True:
            self.mailForwardingAddresses = qr[1]
        else:
            raise web.seeother('/users/%s?msg=%s' %
                               (self.cur_domain, web.urlquote(qr[1])))
        del qr

        # Get all aliases under same domain.
        allAliases = []
        aliasLib = aliaslib.Alias()
        qr = aliasLib.getAllAliases(domain=self.cur_domain,
                                    columns=['name', 'alias', 'deliver_to'])
        if qr[0] is True:
            allAliases = qr[1]

        if session.get('enablePolicyd'):
            # Get sender/recipient throttle data from policyd database.
            throttleLib = throttle.Throttle()
            result_throttle = throttleLib.getThrottling(sender=self.mail,
                                                        recipient=self.mail)
            if result_throttle[0] is True:
                throttleOfSender = result_throttle[1]
                throttleOfRecipient = result_throttle[2]

        return web.render(
            'dbmail_mysql/user/profile.html',
            cur_domain=self.cur_domain,
            mail=self.mail,
            profile_type=self.profile_type,
            profile=self.profile,
            userAliasAddresses=self.userAliasAddresses,
            mailForwardingAddresses=self.mailForwardingAddresses,
            allAliases=allAliases,
            throttleOfSender=throttleOfSender,
            throttleOfRecipient=throttleOfRecipient,
            msg=i.get('msg'),
        )