Add support for modifying users to add/change roles
[scpubgit/stemmatology.git] / lib / Text / Tradition / Directory.pm
index 743ab6c..341da5c 100644 (file)
@@ -293,7 +293,8 @@ sub user_traditionlist {
     
     ## Search for all traditions which allow public viewing
     ## When they exist!
-    # $self->search({ public => 1 });
+## This needs to be more sophisticated, probably needs Search::GIN
+#    my $list = $self->search({ public => 1 });
     
     ## For now, just fetch all
     ## (could use all_objects or grep down there?)
@@ -427,13 +428,20 @@ sub modify_user {
     my ($self, $userinfo) = @_;
     my $username = $userinfo->{username};
     my $password = $userinfo->{password};
+    my $role = $userinfo->{role};
 
-    return unless $username && $self->validate_password($password);
+    return unless $username;
+    return if($password && !$self->validate_password($password));
 
     my $user = $self->find_user({ username => $username });
     return unless $user;
 
-    $user->password(crypt_password($password));
+    if($password) {
+        $user->password(crypt_password($password));
+    }
+    if($role) {
+        $user->role($role);
+    }
 
     $self->update($user);