[Grok-dev] megrok.login

Mats mats at ronin-group.org
Mon May 23 15:34:32 EDT 2011

I'm trying to authenticate using megrok.login but it doesn't
authenticate my user.  It does authenticate using the session login
form against my admin username and password from the grok install.

I created a register form as so:

class Register(base.PageForm):

    fields = base.Fields(IRegister)
    ignoreContext = True

    def handle_registration(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
        username = data['username']
        password = data['password']

        auth = component.getUtility(IAuthentication)
        pf = auth['principals']
        pf[username] = InternalPrincipal(username, password, username)
        pm = IPrincipalPermissionManager(grok.getSite())
        pm.grantPermissionToPrincipal('iport.Registered', username)

My login form looks like this:

class Login(Page):
    def update(self, camefrom=None, SUBMIT=None):
        self.camefrom = camefrom
        if SUBMIT is not None and camefrom is not None:

The registration does seem to work correctly as it adds the principal
to site._sm['megrok_login_pau']['principals'] but authentication gives
me nothing but displaying the login form again and user staying as

What am I doing wrong?



More information about the Grok-dev mailing list