Hello,

I am writing a TG2 web site and I want
to give users the possibility to register.

I have implemented registration
with this basic form (a copy of the default login form):


<form action="${tg.url('/doRegistration')}" method="POST">
          <h2><span>Register</span></h2>
          <label for="login">Username:</label><input type="text"
id="login" name="login" class="text"></input><br/>
          <label for="email">Email:</label><input type="text"
id="email" name="email" class="text"></input><br/>
          <label for="password">Password:</label><input
type="password" id="password" name="password" class="text"></input>
          <input type="submit" id="submit" value="Register" />
      </form>


and this is the doRegistration method :

@expose()
   def doRegistration(self,*arg,**kw):
      userName = kw['login']
      userExists = DBSession.query(model.User).filter_by
(user_name=userName).all()
      if len(userExists) != 0:
         raise RuntimeError('User already exists')   # this is too
basic ...
      newUser = model.User
(user_name=userName,display_name=userName,email_address=kw
['email'],_password=kw['password'])
      users = DBSession.query(model.Group).filter_by
(group_name='users').all()[0]
      newUser.groups.append(users)
      DBSession.add(newUser)
      DBSession.flush()
      redirect('../login')


With this implementation, new users are correctly added
into the db and I can see them with CatWalk.

But I can't login with new user.
I got this error message  (from method login in controllers/root.py):

'Wrong credentials'

And I don't understand why.
Did I miss something ?
Is there any example of registration with TG2 available somewhere ?

Can anyone help ? Please.

Yours, Patrick

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to