X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FAuthentication.pod;h=f3eaa8493668cb7a6965f475b532f60aa4740de9;hp=be80e9832b9746bf64ef0427fdfb489e4e18bdb6;hb=acbd7bddabb7f0d62f0e031e21d440a0ae496d6d;hpb=7c6892d94938b07b1ec201e2aef9695d2d35d3c5 diff --git a/lib/Catalyst/Manual/Tutorial/Authentication.pod b/lib/Catalyst/Manual/Tutorial/Authentication.pod index be80e98..f3eaa84 100644 --- a/lib/Catalyst/Manual/Tutorial/Authentication.pod +++ b/lib/Catalyst/Manual/Tutorial/Authentication.pod @@ -126,18 +126,19 @@ Although we could manually edit the DBIC schema information to include the new tables added in the previous step, let's use the C option on the DBIC model helper to do most of the work for us: - $ script/myapp_create.pl model DB DBIC::Schema MyApp::Schema create=static dbi:SQLite:myapp.db + $ script/myapp_create.pl model DB DBIC::Schema MyApp::Schema \ + create=static components=TimeStamp dbi:SQLite:myapp.db exists "/root/dev/MyApp/script/../lib/MyApp/Model" exists "/root/dev/MyApp/script/../t" Dumping manual schema for MyApp::Schema to directory /root/dev/MyApp/script/../lib ... Schema dump completed. exists "/root/dev/MyApp/script/../lib/MyApp/Model/DB.pm" $ - $ ls lib/MyApp/Schema + $ ls lib/MyApp/Schema/Result Authors.pm BookAuthors.pm Books.pm Roles.pm UserRoles.pm Users.pm Notice how the helper has added three new table-specific result source -files to the C directory. And, more +files to the C directory. And, more importantly, even if there were changes to the existing result source files, those changes would have only been written above the C<# DO NOT MODIFY THIS OR ANYTHING ABOVE!> comment and your hand-edited @@ -148,7 +149,7 @@ relationship information to the three new result source files. Edit each of these files and add the following information between the C<# DO NOT MODIFY THIS OR ANYTHING ABOVE!> comment and the closing C<1;>: -C: +C: # # Set relationships: @@ -159,7 +160,7 @@ C: # 1) Name of relationship, DBIC will create accessor with this name # 2) Name of the model class referenced by this relationship # 3) Column name in *foreign* table (aka, foreign key in peer table) - __PACKAGE__->has_many(map_user_role => 'MyApp::Schema::UserRoles', 'user_id'); + __PACKAGE__->has_many(map_user_role => 'MyApp::Schema::Result::UserRoles', 'user_id'); # many_to_many(): # args: @@ -170,7 +171,7 @@ C: __PACKAGE__->many_to_many(roles => 'map_user_role', 'role'); -C: +C: # # Set relationships: @@ -181,10 +182,10 @@ C: # 1) Name of relationship, DBIC will create accessor with this name # 2) Name of the model class referenced by this relationship # 3) Column name in *foreign* table (aka, foreign key in peer table) - __PACKAGE__->has_many(map_user_role => 'MyApp::Schema::UserRoles', 'role_id'); + __PACKAGE__->has_many(map_user_role => 'MyApp::Schema::Result::UserRoles', 'role_id'); -C: +C: # # Set relationships: @@ -195,25 +196,25 @@ C: # 1) Name of relationship, DBIC will create accessor with this name # 2) Name of the model class referenced by this relationship # 3) Column name in *this* table - __PACKAGE__->belongs_to(user => 'MyApp::Schema::Users', 'user_id'); + __PACKAGE__->belongs_to(user => 'MyApp::Schema::Result::Users', 'user_id'); # belongs_to(): # args: # 1) Name of relationship, DBIC will create accessor with this name # 2) Name of the model class referenced by this relationship # 3) Column name in *this* table - __PACKAGE__->belongs_to(role => 'MyApp::Schema::Roles', 'role_id'); + __PACKAGE__->belongs_to(role => 'MyApp::Schema::Result::Roles', 'role_id'); The code for these three sets of updates is obviously very similar to the edits we made to the C, C, and C classes created in Part 3. -Note that we do not need to make any change to the -C schema file. It simply tells DBIC to -load all of the result class files it finds in below the -C directory, so it will automatically pick -up our new table information. +Note that we do not need to make any change to the +C schema file. It simply tells DBIC to load all +of the Result Class and ResultSet Class files it finds in below the +C directory, so it will automatically pick up our +new table information. =head2 Sanity-Check Reload of Development Server @@ -244,7 +245,7 @@ Look for the three new model objects in the startup debug output: '-------------------------------------------------------------------+----------' ... -Again, notice that your "result class" classes have been "re-loaded" +Again, notice that your "Result Class" classes have been "re-loaded" by Catalyst under C. @@ -253,19 +254,19 @@ by Catalyst under C. Edit C and update it as follows (everything below C is new): - __PACKAGE__->setup(qw/ - -Debug - ConfigLoader - Static::Simple - - StackTrace - - Authentication - - Session - Session::Store::FastMmap - Session::State::Cookie - /); + # Load plugins + use Catalyst qw/-Debug + ConfigLoader + Static::Simple + + StackTrace + + Authentication + + Session + Session::Store::FastMmap + Session::State::Cookie + /; B As discussed in MoreCatalystBasics, different versions of C have used a variety of methods to load the plugins. @@ -344,9 +345,9 @@ C file and update it to match: # Use DBIC to retrieve username, password & role information class DBIx::Class # This is the model object created by Catalyst::Model::DBIC - # from your schema (you created 'MyApp::Schema::User' but as - # the Catalyst startup debug messages show, it was loaded as - # 'MyApp::Model::DB::Users'). + # from your schema (you created 'MyApp::Schema::Result::User' + # but as the Catalyst startup debug messages show, it was + # loaded as 'MyApp::Model::DB::Users'). # NOTE: Omit 'MyApp::Model' here just as you would when using # '$c->model("DB::Users)' user_class DB::Users @@ -545,6 +546,7 @@ changes depending on whether the user has authenticated yet. To do this, open C in your editor and add the following lines to the bottom of the file: + ...

[% # This code illustrates how certain parts of the TT @@ -582,14 +584,23 @@ running) and restart it: B If you are having issues with authentication on Internet Explorer, be sure to check the system clocks on both your server and client machines. Internet Explorer is very picky about -timestamps for cookies. You can quickly sync an Ubuntu system with -the following command: +timestamps for cookies. You can quickly sync a Debian system by +installing the "ntpdate" package: + + sudo aptitude -y install ntpdate + +And then run the following command: - sudo ntpdate ntp.ubuntu.com + sudo ntpdate-debian -Or possibly try C (to us an -unpriviledged port) or C (to try a -different server in case the Ubuntu NTP server is down). +Or, depending on your firewall configuration: + + sudo ntpdate-debian -u + +Note: NTP can be a little more finicky about firewalls because it uses +UDP vs. the more common TCP that you see with most Internet protocols. +Worse case, you might have to manually set the time on your development +box instead of using NTP. Now trying going to L and you should be redirected to the login page, hitting Shift+Reload or Ctrl+Reload @@ -648,12 +659,6 @@ dirty" way to do this: $ perl -MDigest::SHA -e 'print Digest::SHA::sha1_hex("mypass"), "\n"' e727d1464ae12436e899a726da5b2f11d8381b26 - $ - -B If you are following along in Ubuntu, you will need to install -C with the following command to run the example code above: - - sudo aptitude install libdigest-sha-perl B You should probably modify this code for production use to not read the password from the command line. By having the script @@ -716,9 +721,9 @@ C are new, everything else is the same): # Use DBIC to retrieve username, password & role information class DBIx::Class # This is the model object created by Catalyst::Model::DBIC - # from your schema (you created 'MyApp::Schema::User' but as - # the Catalyst startup debug messages show, it was loaded as - # 'MyApp::Model::DB::Users'). + # from your schema (you created 'MyApp::Schema::Result::User' + # but as the Catalyst startup debug messages show, it was + # loaded as 'MyApp::Model::DB::Users'). # NOTE: Omit 'MyApp::Model' here just as you would when using # '$c->model("DB::Users)' user_class DB::Users