1 package Text::Tradition::User;
9 ## 'id' provided by KiokuX::User stores our username
10 has 'password' => (is => 'rw', required => 1);
11 ## Change this default active value if you want/need to have an admin confirm a user after they self-create.
12 has 'active' => (is => 'rw', default => sub { 1; });
13 # 'traits' => ['Array'] ?
14 # https://metacpan.org/module/Moose::Meta::Attribute::Native::Trait::Array
15 has 'traditions' => (is => 'rw', isa => 'ArrayRef[Text::Tradition]', default => sub { [] }, required => 0);
17 # after add_tradition => sub {
18 # $tradition->set_user($self)
19 # unless $tradition->user->id eq $self->id;
26 Text::Tradition::User - Users which own traditions, and can login to the web app
30 ## Users are managed by Text::Tradition::UserStore
32 my $userstore = Text::Tradition::UserStore->new(dsn => 'dbi:SQLite:foo.db');
33 my $newuser = $userstore->add_user({ username => 'fred',
34 password => 'somepassword' });
36 my $fetchuser = $userstore->find_user({ username => 'fred' });
37 if($fetchuser->check_password('somepassword')) {
38 ## login user or .. whatever
41 my $user = $userstore->deactivate_user({ username => 'fred' });
43 ## shouldnt be able to login etc
46 foreach my $t (@{ $user->traditions }) {
47 ## do something with traditions owned by this user.
52 User objects representing owners of L<Text::Tradition>s and authenticated users.
58 Inherited from KiokuX::User, stores the 'username' (login) of the user.
62 User's password, encrypted on creation (by
63 L<KiokuX::User::Util/crypt_password>.
67 Active flag, defaults to true (1). Will be set to false (0) by
68 L<Text::Tradition::UserStore/deactivate_user>.
72 Returns an ArrayRef of L<Text::Tradition> objects belonging to this user.
78 Inherited from KiokuX::User, verifies a given password string against
79 the stored encrypted version.