Helper/Login.pm

filter: Statementstmt 100% 3 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 100% 4 / 4 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« Plugin/Login.pm ↑ Summary
1 package Daje::Helper::Login;
2 1 ▶use Mojo::Base 'Mojolicious::Plugin', -async_await;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 use v5.40;
4  
5 # NAME
6 # ====
7 #
8 # Daje::Helper::Login - Its a
9 #
10 #
11 # DESCRIPTION
12 # ===========
13 #
14 # my $json = encode_json($login);
15 #
16 #
17 # REQUIRES
18 # ========
19 #
20 # Daje::Database::Model::Login
21 #
22 # Daje::Tools::JWT
23 #
24 # v5.40
25 #
26 # Mojo::Base
27 #
28 #
29 # METHODS
30 # =======
31 #
32 #
33 # LICENSE
34 # =======
35 #
36 # Copyright (C) janeskil1525.
37 #
38 # This library is free software; you can redistribute it and/or modify
39 # it under the same terms as Perl itself.
40 #
41 # AUTHOR
42 # ======
43 #
44 # janeskil1525 E<lt>janeskil1525@gmail.comE<gt>
45 #
46  
47 use Data::Dumper;
48 use Daje::Tools::JWT;
49 use Daje::Database::Model::Login;
50 use Digest::SHA qw{sha512_base64};
51  
52 our $VERSION = "0.01";
53  
54 has 'pg';
55  
56 async sub login_user ($self, $userid, $password) {
57  
58 $password = sha512_base64 $password;
59  
60 say "Password: " . Dumper($password);
61 my $login = Daje::Database::Model::Login->new(
62 pg => $self->pg
63 )->login(
64 $userid, $password
65 );
66  
67 my $jwt;
68 my $result;
69  
70 if($login) {
71 #my $json = encode_json($login);
72 $jwt = await Daje::Tools::JWT->new()->encode_jwt_p(
73 $login
74 );
75  
76 $result = {
77 userid => $userid,
78 jwt => $jwt,
79 expires => '',
80 support => $login->{support}
81 };
82 }
83  
84 return $result;
85 }
86 1;
87  
88 #################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################
89  
90 =head1 NAME
91  
92  
93 Daje::Helper::Login - Its a
94  
95  
96  
97  
98 =head1 DESCRIPTION
99  
100  
101 my $json = encode_json($login);
102  
103  
104  
105  
106 =head1 REQUIRES
107  
108  
109 Daje::Database::Model::Login
110  
111 Daje::Tools::JWT
112  
113 v5.40
114  
115 Mojo::Base
116  
117  
118  
119  
120 =head1 METHODS
121  
122  
123  
124  
125  
126 =head1 AUTHOR
127  
128  
129 janeskil1525 E<lt>janeskil1525@gmail.comE<gt>
130  
131  
132  
133 =head1 LICENSE
134  
135  
136 Copyright (C) janeskil1525.
137  
138 This library is free software; you can redistribute it and/or modify
139 it under the same terms as Perl itself.
140  
141  
142  
143 =cut
144  
« Plugin/Login.pm ↑ Summary