From interchange-cvs at icdevgroup.org Thu Jan 24 17:12:10 2013 From: interchange-cvs at icdevgroup.org (Jon Jensen) Date: Thu, 24 Jan 2013 17:12:10 +0000 Subject: [interchange] Add simple tag to generate user-friendly passwords Message-ID: commit cd3e8ed91ad2857546cdd9088e1aae741d29a15d Author: Jon Jensen Date: Thu Jan 24 10:09:44 2013 -0700 Add simple tag to generate user-friendly passwords Takes no options at all. Could profitably have options to control length, characters used, etc., but this has been useful to some of us for years and is simple and has no external dependencies, so might as well get it in here. code/UserTag/make_password.tag | 44 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) --- diff --git a/code/UserTag/make_password.tag b/code/UserTag/make_password.tag new file mode 100644 index 0000000..3049fdd --- /dev/null +++ b/code/UserTag/make_password.tag @@ -0,0 +1,44 @@ +# Copyright 2003-2013 Jon Jensen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. See the LICENSE file for details. + +Usertag make-password Routine < 7; + if ($last_numbers) { + $l = 1; + } + elsif ($_ > 2) { + undef $l if ! $did_numbers; + $l = 1 if ! $did_letters; + } + if ($l) { + $pass .= $c[rand @c] . $v[rand @v]; + $pass .= $c2[rand @c2] if rand(10) > 5; + ++$did_letters; + undef $last_numbers; + } + else { + $pass .= $d[rand @d]; + $pass .= $d[rand @d] if rand(10) > 3; + ++$did_numbers; + $last_numbers = 1; + } + redo if $_ > 2 and length($pass) < 8; + } + return $pass; +} +EOR From interchange-cvs at icdevgroup.org Tue Jan 29 16:05:43 2013 From: interchange-cvs at icdevgroup.org (Mark Johnson) Date: Tue, 29 Jan 2013 16:05:43 +0000 Subject: [interchange] New UserDB option for read-only attribute Message-ID: commit d36488397ae357ec4ecaa0362da9cca56f7ed834 Author: Mark Johnson Date: Tue Jan 29 10:30:53 2013 -0500 New UserDB option for read-only attribute * Identifies fields for which the session value will not overwrite the database value. Useful for protected fields that are only to be managed by site administrators, particularly for outboard fields where you don't want [userdb] to try to create an outboard record at all. * Syntax similar to UserDB 'scratch' attribute, but only valid for keys: UserDb default read_only 'field1, field2, field3' lib/Vend/UserDB.pm | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) --- diff --git a/lib/Vend/UserDB.pm b/lib/Vend/UserDB.pm index 94ef5d0..7e6c776 100644 --- a/lib/Vend/UserDB.pm +++ b/lib/Vend/UserDB.pm @@ -951,6 +951,12 @@ sub set_values { my %scratch; my %constant; my %session_hash; + my %read_only; + + if ($self->{OPTIONS}{read_only}) { + my (@s) = grep /\w/, split /[\s,]+/, $self->{OPTIONS}{read_only} ; + $read_only{$_} = 1 for @s; + } if($self->{OPTIONS}->{scratch}) { my (@s) = grep /\w/, split /[\s,]+/, $self->{OPTIONS}{scratch} ; @@ -1013,6 +1019,10 @@ sub set_values { #::logDebug("set_values saving $_ as $valref->{$_}\n"); my $val; my $k; + if ($read_only{$_}) { + # Pull from get_values only; never write through set_values + next; + } if ($k = $scratch{$_}) { $val = $scratchref->{$k} if defined $scratchref->{$k};