예제 #1
0
                emails.extend(domain.aliases)
        return emails

    def send_welcome(self):
        if app.config["WELCOME"].lower() == "true":
            self.sendmail(app.config["WELCOME_SUBJECT"],
                          app.config["WELCOME_BODY"])

    @classmethod
    def login(cls, email, password):
        user = cls.query.get(email)
        return user if (user and user.enabled
                        and user.check_password(password)) else None


login_manager.user_loader(User.query.get)


class Alias(Base, Email):
    """ An alias is an email address that redirects to some destination.
    """
    __tablename__ = "alias"

    domain = db.relationship(Domain,
                             backref=db.backref('aliases',
                                                cascade='all, delete-orphan'))
    wildcard = db.Column(db.Boolean(), nullable=False, default=False)
    destination = db.Column(CommaSeparatedList, nullable=False, default=[])


class Token(Base):
예제 #2
0
파일: models.py 프로젝트: insxa/Mailu
            emails.extend(domain.users)
            if include_aliases:
                emails.extend(domain.aliases)
        return emails

    def send_welcome(self):
        if app.config["WELCOME"].lower() == "true":
            self.sendmail(app.config["WELCOME_SUBJECT"],
                app.config["WELCOME_BODY"])

    @classmethod
    def login(cls, email, password):
        user = cls.query.get(email)
        return user if (user and user.enabled and user.check_password(password)) else None

login_manager.user_loader(User.query.get)


class Alias(Base, Email):
    """ An alias is an email address that redirects to some destination.
    """
    __tablename__ = "alias"

    domain = db.relationship(Domain,
        backref=db.backref('aliases', cascade='all, delete-orphan'))
    wildcard = db.Column(db.Boolean(), nullable=False, default=False)
    destination = db.Column(CommaSeparatedList, nullable=False, default=[])


class Token(Base):
    """ A token is an application password for a given user.
예제 #3
0
from flask import Blueprint
from mailu import login_manager, db

import flask_login

app = Blueprint('admin',
                __name__,
                template_folder='templates',
                static_folder='static')

# Import models
from mailu.admin import models

# Register the login components
login_manager.login_view = "admin.login"
login_manager.user_loader(models.User.query.get)


@app.context_processor
def inject_user():
    return dict(current_user=flask_login.current_user)


# Import views
from mailu.admin.views import \
    admins, \
    managers, \
    base, \
    aliases, \
    users, \
    domains, \