コード例 #1
0
ファイル: core.py プロジェクト: zyhndesign/hnu-pinwall-latest
def _get_login_manager(app):
    lm = LoginManager()
    lm.anonymous_user = AnonymousUser
    lm.login_view = '%s.login' % cv('BLUEPRINT_NAME', app=app)
    lm.user_loader(_user_loader)
    lm.login_message = None
    lm.needs_refresh_message = None
    lm.unauthorized_callback = lambda: abort(401)
    lm.init_app(app)
    return lm
コード例 #2
0
ファイル: web.py プロジェクト: getnikola/coil
    """Log a request."""
    l = "[{4}] {0} {1} {2} <{3}>".format(request.remote_addr, request.method,
                                         request.url, request.endpoint,
                                         resp.status_code)
    c = str(resp.status_code)[0]
    if c in ['1', '2'] or resp.status_code == 304:
        app.http_logger.info(l)
    elif c == '3':
        app.http_logger.warn(l)
    else:
        app.http_logger.error(l)
    return resp

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.unauthorized_callback = _unauthorized


class User(object):
    """An user.  Compatible with Flask-Login."""
    def __init__(self, uid, username, realname, password, email, active,
                 is_admin, can_edit_all_posts, wants_all_posts,
                 can_upload_attachments, can_rebuild_site,
                 can_transfer_post_authorship, must_change_password):
        """Initialize an user with specified settings."""
        self.uid = int(uid)
        self.username = username
        self.realname = realname
        self.password = password
        self.email = email
        self.active = active
コード例 #3
0
    """Log a request."""
    l = "[{4}] {0} {1} {2} <{3}>".format(request.remote_addr, request.method,
                                         request.url, request.endpoint,
                                         resp.status_code)
    c = str(resp.status_code)[0]
    if c in ['1', '2'] or resp.status_code == 304:
        app.http_logger.info(l)
    elif c == '3':
        app.http_logger.warn(l)
    else:
        app.http_logger.error(l)
    return resp

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.unauthorized_callback = _unauthorized


class User(object):
    """An user.  Compatible with Flask-Login."""
    def __init__(self, uid, username, realname, password, email, active,
                 is_admin, can_edit_all_posts, wants_all_posts,
                 can_upload_attachments, can_rebuild_site,
                 can_transfer_post_authorship, must_change_password):
        """Initialize an user with specified settings."""
        self.uid = int(uid)
        self.username = username
        self.realname = realname
        self.password = password
        self.email = email
        self.active = active