summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2023-01-22 12:33:02 +0100
committerDaniel Friesel <derf@finalrewind.org>2023-01-22 12:33:02 +0100
commit8e94fcea5ff99023c108da0f58abb421f16454e8 (patch)
tree160df6bf04d36b8914d5ed156d50673092beecd1
parent59e9a24aa63d0209ea301b2c4aa71687e8295be6 (diff)
move token type to ID map from Travelynx.pm to Model/Users
-rwxr-xr-xlib/Travelynx.pm11
-rwxr-xr-xlib/Travelynx/Controller/Api.pm2
-rw-r--r--lib/Travelynx/Model/Users.pm12
3 files changed, 13 insertions, 12 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 9bd6ebe..6aea580 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -160,17 +160,6 @@ sub startup {
);
$self->attr(
- token_type => sub {
- return {
- status => 1,
- history => 2,
- travel => 3,
- import => 4,
- };
- }
- );
-
- $self->attr(
account_public_mask => sub {
return {
status_intern => 0x01,
diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm
index 6f788b5..7164b5b 100755
--- a/lib/Travelynx/Controller/Api.pm
+++ b/lib/Travelynx/Controller/Api.pm
@@ -571,7 +571,7 @@ sub set_token {
return;
}
my $token = make_token();
- my $token_id = $self->app->token_type->{ $self->param('token') };
+ my $token_id = $self->users->get_token_id( $self->param('token') );
if ( not $token_id ) {
$self->redirect_to('account');
diff --git a/lib/Travelynx/Model/Users.pm b/lib/Travelynx/Model/Users.pm
index 0287ca2..46ffbdd 100644
--- a/lib/Travelynx/Model/Users.pm
+++ b/lib/Travelynx/Model/Users.pm
@@ -19,6 +19,12 @@ my @sb_templates = (
[ 'bahn.expert/regional', 'https://bahn.expert/regional/{name}#{id}' ],
);
+my %token_id = (
+ status => 1,
+ history => 2,
+ travel => 3,
+ import => 4,
+);
my @token_types = (qw(status history travel import));
sub new {
@@ -27,6 +33,12 @@ sub new {
return bless( \%opt, $class );
}
+sub get_token_id {
+ my ( $self, $type ) = @_;
+
+ return $token_id{$type};
+}
+
sub mark_seen {
my ( $self, %opt ) = @_;
my $uid = $opt{uid};