Hi, I studied the source code of auth.login() and found that all the validations are applied within the login method itself. The error message is automatically written to an element of class flash via setting session.flash to auth.messages.invalid_login.
I modified my view code to include the class attribute of the <td> and set its value to "flash" as below: <td class="flash">{{=response.flash}}</td> Now one can modify the CSS and JS to control how the element is displayed. As far as I understand, to achieve the required functionality of displaying form errors via form.errors.email etc., one can either extend Auth and override the login() method or build a custom login functionality. Let me know if there is an easier way On Tuesday, March 13, 2012 11:02:54 AM UTC+5:30, Sushant Taneja wrote: > > Hi, > > Ah, I forget that form.custom.begin is an XML object (more like a string) >> and doesn't change when you directly manipulate the form object itself. You >> could do: >> >> f.custom.begin = '%s id="login">' % f.custom.begin[:-1] >> > > I added the above code line in controller. The attribute id was added to > the form element, but the whole <form> being tag was rendered as : > > *"* > <form method="post" id="login">*"* > * > * > i.e form is displayed a text element and hence JS was not working on it. > > > >> if login_form.errors: >>> login_form.errors.email='Email/Password does not match' >>> >>> return dict(login_form=login_form) >>> >>> In the view I have : >>> >>> <tr class="error"> >>> <td colspan="2"><!-- Show error here --></td> >>> </tr> >>> >> >> Maybe something like: >> >> {{if login_form.errors.email:}} >> <tr class="error"> >> <td colspan="2">{{=login_form.errors.email}}</td> >> </tr> >> {{pass}} >> >> > I didn't want to render the <tr> element dynamically, so I tried the > following: > > <tr class="error"> > <td colspan="2"> > {{if login_form.errors:}} > {{=login_form.errors.email}} > {{pass}} > </td> > </tr> > > But nothing is happening. > In usual cases, if I leave the field empty or enter an invalid email > address, an error is displayed but not in this case. > Even if there are errors, the *login_form.errors* object is empty and > nothing is displayed. > > How does auth handle authentication errors ? > >