On Thu, Sep 13, 2007 at 10:27:04AM +0100, Ian Docherty wrote: > Hi > > My existing Catalyst application is being extended. I want to keep a > record of previous passwords used by a user to prevent them being re-used. > > I have Model 'UsedPassword' to keep track of the previous 8 (say) > passwords as so- > > package MyApp::Schema::UsedPassword; > use strict; > use base qw(DBIx::Class); > > __PACKAGE__->load_components(qw(PK::Auto Core)); > __PACKAGE__->table('used_password'); > __PACKAGE__->add_columns(qw(id user password)); > __PACKAGE__->set_primary_key('id'); > > So, if I want a method (create_limited) to create a new UsedPassword > object, that ensures no more that 8 (say) passwords are stored in the > database (against each User) where should it go? > > Ideally (I think) I would like to do something like > > $c->model('DBIC::UsedPassword')->create_limited({ > user => $user->id, > password => $password, > }); > > but i can't see how to add it to MyApp::Schema::UsedPassword (since > $c->model('DBIC::UsedPassword') returns a ResultSet not a > MyApp::Schema::UsedPassword) > > Any other suggestions where to put it (polite one's only please)? ^^ BLAM!
Why not just have it as $user->_add_to_used_passwords and then hook that into $user->insert + ->update ? Perhaps better still, why not just make this a trigger? (unless you're using MySQL, in which case s/make this a trigger/use a database/ :) -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Director Want a managed development or deployment platform? Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/ _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/