+++ /dev/null
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-
-use v5.10.0;
-
-use Getopt::Long;
-use Text::Tradition::UserStore;
-
-use lib 'lib';
-
-my ($dsn, $command) = ('dbi:SQLite:dbname=db/traditions.db', 'add', undef);
-my ($username, $password);
-
-GetOptions(
- 'c|command:s' => \$command,
- 'dsn:s' => \$dsn,
- 'u|username=s' => \$username,
- 'p|password:s' => \$password,
- ) or usage();
-
-if(!$command || !($command ~~ [qw/add modify delete/])) {
- print "No command supplied, chickening out ... \n\n";
- usage();
-}
-
-if(!$username) {
- print "No username supplied, confused ... \n\n";
- usage();
-}
-
-my $userstore = Text::Tradition::UserStore->new( dsn => $dsn);
-
-given ($command) {
- when ('add') {
- if(!$password || !$userstore->validate_password($password)) {
- print "Can't add a new user without a valid password\n\n";
- usage();
- }
- my $user = $userstore->add_user({ username => $username,
- password => $password });
- if(!$user) {
- print "Failed to add user! (you should see errors above this..)\n";
- } else {
- print "OK.\n";
- }
- }
-
- when ('modify') {
- if(!$password || !$userstore->validate_password($password)) {
- print "Can't modify a user without a valid password\n\n";
- usage();
- }
- my $user = $userstore->modify_user({ username => $username,
- password => $password });
- if(!$user) {
- print "Failed to modify user! (you should see errors above this..)\n";
- } else {
- print "OK.\n";
- }
- }
- when ('delete') {
- my $user = $userstore->delete_user({ username => $username});
- if(!$user) {
- print "Failed to modify user! (you should see errors above this..)\n";
- } else {
- print "OK.\n";
- }
- }
-}
-
-sub usage {
- print "User Admin tool, to add/remove/modify users\n";
- print "===========================================\n";
- print "Usage: $0 -c add -u jimbob -p hispassword\n";
- print "Usage: $0 -c modify -u jimbob -p hisnewpassword\n";
- print "Usage: $0 -c delete -u jimbob\n";
-}
-
-=head1 NAME
-
-admin_users.pl - add / modify / delete users
-
-=head1 SYNOPSIS
-
- admin_user.pl -c add -u jimbob -p "jimspassword"
-
- admin_user.pl -c modify -u jimbob -p "jimsnewpassword"
-
- admin_user.pl -c delete -u jimbob
-
-=head1 OPTIONS
-
-=over
-
-=item -c | --command
-
-The action to take, can be one of: add, modify, delete.
-
-=item -u | --username
-
-The username of the new user or user to change.
-
-=item -p | --password
-
-The new password or password to change.
-
-=back
+++ /dev/null
-package stemmaweb::Model::User;
-use strict;
-use warnings;
-use Moose;
-use Text::Tradition::UserStore;
-
-extends 'Catalyst::Model::KiokuDB';
-
-has '+model_class' => ( default => 'Text::Tradition::UserStore' );
-
-1;
-
-=head1 NAME
-
-stemmaweb::Model::User - User/Auth KiokuDB model for stemmaweb
-
-=head1 SYNOPSIS
-
- ## CONFIGURATION, in .conf file (this is the default setting)
- <Model::User>
- model_class Text::Tradition::UserStore
- </Model::User>
-
- <Plugin::Authentication>
- <default>
- <credential>
- class 'Password'
- password_field 'password'
- password_type 'self_check'
- </credential>
- <store>
- class 'Model::KiokuDB'
- model_name 'User'
- </store>
- </default>
- </Plugin::Authentication>
-
-
-=head1 DESCRIPTION
-
-This is the User Model used as a Authentication Store (using
-::Store::Model::KiokuDB) for stemmaweb user authentication.
-
-This separate model allows us to have self-contained user storage,
-which is replaceable. The default uses Text::Tradition::UserStore and
-stores the Users alongside the Traditions.
-
-To replace the source of users for authentication, add the
-configuration shown in the L</SYNOPSIS> to your stemmaweb.conf file,
-and adjust as necessary.