summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-07-25 22:26:23 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-07-25 22:27:26 (GMT)
commit816e4193f4b9d5f40267ebc569afef471b7f5786 (patch)
tree43f42b4cc6b18dd83ce30b32aef19d68c016083e /lib
parent5a7e793f8d3d559b519c6c5ab4a386028a0e1106 (diff)
added update-rd-tokens util
Diffstat (limited to 'lib')
-rwxr-xr-xlib/RHRD/rddb.pm34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 63a182c..ee49444 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -72,6 +72,20 @@ sub get_token
return ($token, 'OK', 'success');
}
+sub set_token
+{
+ my ($dbh, $username, $token) = @_;
+
+ my $sql = qq{update USERS set PASSWORD = ? where LOGIN_NAME = ?;};
+ my $rows = $dbh->do($sql, undef, $token, $username)
+ or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
+
+ unless($rows == 1) {
+ return (undef, 'ERROR', "user '" . $username . "' not known by rivendell")
+ }
+ return ($token, 'OK', 'success');
+}
+
sub check_token
{
my ($dbh, $username, $token) = @_;
@@ -96,6 +110,26 @@ sub check_token
return (0, 'ERROR', "wrong password");
}
+sub get_users
+{
+ my ($dbh) = @_;
+
+ my $sql = qq{select LOGIN_NAME from USERS order by LOGIN_NAME;};
+ my $sth = $dbh->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
+
+ $sth->execute()
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my @users;
+ while(my ($user) = $sth->fetchrow_array()) {
+ push @users, $user;
+ }
+ $sth->finish();
+
+ return @users;
+}
+
sub get_showtitle_and_log
{
my ($dbh, $showid) = @_;