<commit_before># -*- coding: utf-8 -*-

"""
byceps.blueprints.authentication.session
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from flask import session

from .service import load_user


KEY_USER_ID = 'user_id'
KEY_USER_AUTH_TOKEN = '<PASSWORD>'


class UserSession(object):

    @classmethod
    def start(cls, user, *, permanent=False):
        """Initialize the user's session by putting the relevant data
        into the session cookie.
        """
        session[KEY_USER_ID] = str(user.id)
        session[KEY_USER_AUTH_TOKEN] = str(user.auth_token)
        session.permanent = permanent

    @classmethod
    def end(cls):
        """End the user's session by deleting the session cookie."""
        session.pop(KEY_USER_ID, None)
        session.pop(KEY_USER_AUTH_TOKEN, None)
        session.permanent = False

    @classmethod
    def get_user(cls):
        """Return the current user, falling back to the anonymous user."""
        return load_user(cls.get_user_id(), cls.get_auth_token())

    @classmethod
    def get_user_id(cls):
        """Return the current user's ID, or `None` if not available."""
        return session.get(KEY_USER_ID)

    @classmethod
    def get_auth_token(cls):
        """Return the current user's auth token, or `None` if not available."""
        return session.get(KEY_USER_AUTH_TOKEN)<commit_msg>Don't use a class method where a static method is sufficient.<commit_after># -*- coding: utf-8 -*-

"""
byceps.blueprints.authentication.session
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from flask import session

from .service import load_user


KEY_USER_ID = 'user_id'
KEY_USER_AUTH_TOKEN = 'user_auth_token'


class UserSession(object):

    @staticmethod
    def start(user, *, permanent=False):
        """Initialize the user's session by putting the relevant data
        into the session cookie.
        """
        session[KEY_USER_ID] = str(user.id)
        session[KEY_USER_AUTH_TOKEN] = str(user.auth_token)
        session.permanent = permanent

    @staticmethod
    def end():
        """End the user's session by deleting the session cookie."""
        session.pop(KEY_USER_ID, None)
        session.pop(KEY_USER_AUTH_TOKEN, None)
        session.permanent = False

    @classmethod
    def get_user(cls):
        """Return the current user, falling back to the anonymous user."""
        return load_user(cls.get_user_id(), cls.get_auth_token())

    @staticmethod
    def get_user_id():
        """Return the current user's ID, or `None` if not available."""
        return session.get(KEY_USER_ID)

    @staticmethod
    def get_auth_token():
        """Return the current user's auth token, or `None` if not available."""
        return session.get(KEY_USER_AUTH_TOKEN)
{'fraction_non_alphanumeric': 0.1321145222490514, 'fraction_numerical': 0.006209037599172128, 'mean_word_length': 3.2459736456808197, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7552465', 'n_tokens_mistral': 878, 'n_tokens_neox': 841, 'n_words': 242}