<commit_before>from roundup.cgi.actions import LoginAction
from roundup.cgi import exceptions
from roundup.i18n import _

import ssoapi

class SelvbetjeningLoginAction(LoginAction):
    def verifyLogin(self, username, password):
        sso = ssoapi.SelvbetjeningIntegrationSSO()

        try:
            sso.authenticate(username, password)
        except ssoapi.AuthWrongCredentialsException:
            raise exceptions.LoginError, self._('Invalid login')
        except ssoapi.AuthUserInactiveException:
            raise exceptions.LoginError, self._('Inactive user')
        except ssoapi.AuthMalformedInputException:
            raise exceptions.LoginError, self._('Malformed credentials')
        except ssoapi.AuthUnknownException:
            raise exceptions.LoginError, self._('Unknown authentication error')
        except ssoapi.AuthenticationServerException:
            raise exceptions.LoginError, self._('Authentication server error')

        try:
            self.db.user.lookup(username)
        except KeyError:
            self._create_profile()

    def _create_profile(self):
        self.journaltag = 'admin'

        self.db.user.create(roles=self.db.config.NEW_WEB_USER_ROLES)
        self.db.commit()

def init(instance):
    instance.registerAction('login', SelvbetjeningLoginAction)<commit_msg>Rettet fejl i oprettelsen af nye profiler i roundup sso integrationen.<commit_after>from roundup.cgi.actions import LoginAction
from roundup.cgi import exceptions
from roundup.i18n import _

import ssoapi

class SelvbetjeningLoginAction(LoginAction):
    def verifyLogin(self, username, password):
        sso = ssoapi.SelvbetjeningIntegrationSSO()

        try:
            sso.authenticate(username, password)
        except ssoapi.AuthWrongCredentialsException:
            raise exceptions.LoginError, self._('Invalid login')
        except ssoapi.AuthUserInactiveException:
            raise exceptions.LoginError, self._('Inactive user')
        except ssoapi.AuthMalformedInputException:
            raise exceptions.LoginError, self._('Malformed credentials')
        except ssoapi.AuthUnknownException:
            raise exceptions.LoginError, self._('Unknown authentication error')
        except ssoapi.AuthenticationServerException:
            raise exceptions.LoginError, self._('Authentication server error')

        try:
            self.db.user.lookup(username)
        except KeyError:
            self._create_profile(username)

    def _create_profile(self, username):
        self.journaltag = 'admin'

        self.db.user.create(username=username, roles=self.db.config.NEW_WEB_USER_ROLES)
        self.db.commit()

def init(instance):
    instance.registerAction('login', SelvbetjeningLoginAction)
{'fraction_non_alphanumeric': 0.08005822416302766, 'fraction_numerical': 0.001455604075691412, 'mean_word_length': 3.2162576687116564, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2140866', 'n_tokens_mistral': 750, 'n_tokens_neox': 728, 'n_words': 153}