Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Perl and Ajax Question

by Anonymous Monk
on Feb 02, 2010 at 21:03 UTC ( [id://821035]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!

I am going to build this application and part of that the user will have to login with username and password. I need to check if the password is older than 45 days, if its a yes I need to prompt for the user to change this password and show a message saying that the password has been changed. I want to user Ajax with Perl, any suggestion on this? Has anybody done something like that where I could see some code sample?

Thank you for the Help!!!

Replies are listed 'Best First'.
Re: Perl and Ajax Question
by Corion (Patriarch) on Feb 02, 2010 at 21:19 UTC

    First, write the whole thing as a normal CGI+pure HTML page, and get the functionality working that way.

    After you have the working application, it's easy to add a toolkit like jQuery to re-style the "You need to change your password" message.

    Your application needs to work with Javascript disabled, otherwise users will circumvent the password change prompt by disabling Javascript.

Re: Perl and Ajax Question
by Your Mother (Archbishop) on Feb 02, 2010 at 22:12 UTC

    Catalyst has drop in sessioning and such but you will have to set-up your DB/tables to match and while what you're doing is pretty common, it's not in any code samples or guides I know. This is not what I would call trivial. Any single piece of it is easy but it sounds like you're shooting for real security and that is not easy. Even experienced devs get it wrong quite often.

    The main thing is what Corion said: forget about Ajax until you have working code with regular HTTP/CGI. At that point jQuery or a few other high level packages make it really quite simple. Again, it's straightforward once you know what you're doing. It's actually extremely difficult if you haven't done it before because there are many small pieces to understand. Not to dissuade, just to let you know that even with help and some prefab code this is not a small project if it's your first stab it.

Re: Perl and Ajax Question
by dsheroh (Monsignor) on Feb 03, 2010 at 10:16 UTC
    ObRepetitionToDriveThePointHome: First get it working with plain old HTML, then add the AJAX functionality as an optional enhancement for those users who have the necessary features (Javascript) enabled in their browser.

    When it comes time to add the AJAX piece, I've found that CGI::Ajax is, far and away, the easiest way to do AJAX with Perl. (I'm not going to claim it's the most efficient, but it is the easiest.)

      I used CGI::Ajax when I was first starting out with Ajax & Perl, but it has several really problematic things that it does- especially with properly encoding the query strings.

      These days I just use the Ajax functions in jQuery (they are more powerful anyway) and use JSON if I'm outputting data or sometimes just return HTML.

      CGI::Ajax is fine for when you first start using AJAX but once you understand how it all works together, you really are better off doing it yourself.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://821035]
Approved by AnomalousMonk
Front-paged by MadraghRua
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-28 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found