Database/Model/UsersVerificationCodes.pm

filter: Statementstmt 33.3% 1 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 50.0% 2 / 4 CC 1 SCAR 2.6
CC
1
Cov
33%
BEGIN
1.3
CRAP 1.3
« Database/Model/UsersUsers.pm ↑ Summary Helper/Users/Login.pm »
1 package Daje::Database::Model::UsersVerificationCodes;
2 0 ▶use Mojo::Base 'Daje::Database::Model::Super::UsersVerificationCodes', -base, -async_await, -signatures;
Subroutine BEGIN: called CC=1 SCAR=2.6
3 use v5.42;
4  
5 # NAME
6 # ====
7 #
8 # Daje::Database::Model::UsersVerificationCodes - Model class
9 #
10 # SYNOPSIS
11 # ========
12 #
13 # use Daje::Database::Model::UsersVerificationCodes;
14 #
15 # my $class = Daje::Database::Model::UsersVerificationCodes->new(db => $db);
16 #
17 # DESCRIPTION
18 # ===========
19 #
20 # Daje::Database::Model::UsersVerificationCodes is the model
21 #
22 # class that's only generated once. It inherits all
23 #
24 # methods from Daje::Database::Model::Super::UsersVerificationCodes#
25 # This class is meant for non standard methods.
26 #
27 # METHODS
28 # =======
29 #
30 #
31 # LICENSE
32 # =======
33 #
34 # Copyright (C) janeskil1525.
35 #
36 # This library is free software; you can redistribute it and/or modify
37 # it under the same terms as Perl itself.
38 #
39 # AUTHOR
40 # ======
41 #
42 # janeskil1525 E<lt>janeskil1525@gmail.com
43 #
44  
45 # This file is generated once automatically by Daje Tools 2026-02-01 14:13:34.
46 # It will not be touched by Daje Tools again.
47 # <!-- Autogenerated file 2026-02-01 14:13:34 -->
48  
49  
50 our $VERSION = '0.01';
51 use Data::Dumper;
52  
53 sub save_verification_code($self, $mail, $verification_code) {
54  
55 my $verification_stmt = qq{
56 INSERT INTO users_verification_codes (users_users_fkey, verification_code)
57 VALUES((SELECT users_users_pkey FROM users_users WHERE mail = ?), ?)
58 ON CONFLICT(users_users_fkey)
59 DO UPDATE SET verification_code = ?, moddatetime = NOW()
60 RETURNING users_verification_codes_pkey;
61 };
62  
63 my $login_verification_codes_pkey = $self->db->query(
64 $verification_stmt,($mail, $verification_code, $verification_code)
65 )->{login_verification_codes_pkey};
66  
67 return $login_verification_codes_pkey;
68 }
69  
70 sub check_verify($self, $mail, $verification_code) {
71 my $verification_stmt = qq{
72 SELECT users_verification_codes_pkey FROM users_verification_codes
73 WHERE users_users_fkey = (SELECT users_users_pkey FROM users_users WHERE mail = ?) and verification_code = ?;
74 };
75  
76 my $hash = $self->db->query(
77 $verification_stmt,($mail, $verification_code)
78 );
79  
80 return 1 if $hash && $hash->hash->{users_verification_codes_pkey} > 0;
81 return 0;
82 }
83  
84 1;
85  
« Database/Model/UsersUsers.pm ↑ Summary Helper/Users/Login.pm »