<commit_before># from .. import logAccess
from flask.ext.stormpath import StormpathManager
from flask.ext.stormpath import user
from flask.ext.stormpath import login_required
from stormpath.error import Error
import flask as fk

import hashlib
import datetime

# No admin access for now.
# Only user access is handled.

class AccessManager:
    def __init__(self, app):
        """Initializes an access manager instance.
        """
        self.config = app.config['ACCOUNT_MANAGEMENT']
        self.secur = app.config['SECURITY_MANAGEMENT']['account']

        if self.config['type'] == 'stormpath':
            self.manager = StormpathManager(app)
            self.type = 'stormpath'
        elif self.config['type'] == 'api-token':
            self.manager = None
            self.type = 'api-token'
        elif self.config['type'] == 'mongodb':
            self.manager = None
            self.type = 'mongodb'

    def create_account(self, email, password, fname, lname, mname):
        """Create an account.
            Returns:
                Tuple of the account object and a message in case of an error.
        """
        try:
            _account = self.manager.application.accounts.create({
                'email': email,
                'password': password,
                "username" : email,
                "given_name" : fname,
                "middle_name" : mname,
                "surname" : lname,
            })
            return (_account, "")
        except Error as re:
            print('Message: %s' %re.message)
            print('HTTP Status: %s' %str(re.status))
            print('Developer Message: %s' %re.developer_message)
            print('More Information: %s' %re.more_info)
            print('Error Code: %s' %str(re.code))
            print('Message message: %s' %re.message['message'])
            return (None, re.message['message'])

    def register(self, email, password, fname, lname, mname):
        """Registration handler.
            Returns:
                User account registered.
        """
        from corrdb.common.models import UserModel
        account = None
        hash_pwd = hashlib.sha256(('CoRRPassword_%s'%password).encode("ascii")).hexdigest()
        if self.type == 'api-token':<commit_msg>Probably a change in Stormpath's API.<commit_after># from .. import logAccess
from flask.ext.stormpath import StormpathManager
from flask.ext.stormpath import user
from flask.ext.stormpath import login_required
from stormpath.error import Error
import flask as fk

import hashlib
import datetime

# No admin access for now.
# Only user access is handled.

class AccessManager:
    def __init__(self, app):
        """Initializes an access manager instance.
        """
        self.config = app.config['ACCOUNT_MANAGEMENT']
        self.secur = app.config['SECURITY_MANAGEMENT']['account']

        if self.config['type'] == 'stormpath':
            self.manager = StormpathManager(app)
            self.type = 'stormpath'
        elif self.config['type'] == 'api-token':
            self.manager = None
            self.type = 'api-token'
        elif self.config['type'] == 'mongodb':
            self.manager = None
            self.type = 'mongodb'

    def create_account(self, email, password, fname, lname, mname):
        """Create an account.
            Returns:
                Tuple of the account object and a message in case of an error.
        """
        try:
            _account = self.manager.application.accounts.create({
                'email': email,
                'password': password,
                "username" : email,
                "given_name" : fname,
                "middle_name" : mname,
                "surname" : lname,
            })
            return (_account, "")
        except Error as re:
            print('Message: %s' %re.message)
            print('HTTP Status: %s' %str(re.status))
            print('Developer Message: %s' %re.developer_message)
            print('More Information: %s' %re.more_info)
            print('Error Code: %s' %str(re.code))
            print('Message message: %s' %re.message)
            return (None, re.message)

    def register(self, email, password, fname, lname, mname):
        """Registration handler.
            Returns:
                User account registered.
        """
        from corrdb.common.models import UserModel
        account = None
        hash_pwd = hashlib.sha256(('<PASSWORD>'%password).encode("ascii")).hexdigest()
        if self.type == 'api-token':
{'fraction_non_alphanumeric': 0.1158173395102581, 'fraction_numerical': 0.0013236267372600927, 'mean_word_length': 2.044996642041639, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '927503', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1221, 'n_words': 340}