1 package Text::Tradition::User;
9 ## 'id' provided by KiokuX::User stores our username
10 has 'password' => (is => 'rw', required => 1);
11 has 'active' => (is => 'rw', default => sub { 1; });
12 # 'traits' => ['Array'] ?
13 # https://metacpan.org/module/Moose::Meta::Attribute::Native::Trait::Array
14 has 'traditions' => (is => 'rw', isa => 'ArrayRef[Text::Tradition]', required => 0);
16 # after add_tradition => sub {
17 # $tradition->set_user($self)
18 # unless $tradition->user->id eq $self->id;
25 Text::Tradition::User - Users which own traditions, and can login to the web app
29 ## Users are managed by Text::Tradition::UserStore
31 my $userstore = Text::Tradition::UserStore->new(dsn => 'dbi:SQLite:foo.db');
32 my $newuser = $userstore->add_user({ username => 'fred',
33 password => 'somepassword' });
35 my $fetchuser = $userstore->find_user({ username => 'fred' });
36 if($fetchuser->check_password('somepassword')) {
37 ## login user or .. whatever
40 my $user = $userstore->deactivate_user({ username => 'fred' });
42 ## shouldnt be able to login etc
45 foreach my $t (@{ $user->traditions }) {
46 ## do something with traditions owned by this user.
51 User objects representing owners of L<Text::Tradition>s and authenticated users.
57 Inherited from KiokuX::User, stores the 'username' (login) of the user.
61 User's password, encrypted on creation (by
62 L<KiokuX::User::Util/crypt_password>.
66 Active flag, defaults to true (1). Will be set to false (0) by
67 L<Text::Tradition::UserStore/deactivate_user>.
71 Returns an ArrayRef of L<Text::Tradition> objects belonging to this user.
77 Inherited from KiokuX::User, verifies a given password string against
78 the stored encrypted version.