application/Controllers/ViewControllers/User.php
/**
     * Resend verification for unverified emails
     * Allow after 10 minutes of last request
     * Add new token to database
     * Resend email for verification
     * 
     * @route
     */
Resend verification for unverified emails
Allow after 10 minutes of last request
Add new token to database
Resend email for verification

@route
Resend verification for unverified emails Allow after 10 minutes of last request Add new token to database Resend email for verification @route
public function resendVerification(): void {
        $data['error'] = '';
        $data['default_mail'] = $_GET['email'] ?? '';
        if(Server::checkPostReq(['email'])) {
            $email = $_POST['email'];
            $lastIssued = strtotime($this->userModel->checkVerificationRequestTime($email));
            if(!$this->userModel->ifEmailExists($email)) {
                $data['error'] = "Email not found";
            }   else if($this->userModel->isVerifiedEmail($email)) {
                $data['error'] = "Email already verified";
            }   else if(time() - $lastIssued < 600) {
                $data['error'] = "Please wait 10 minutes to resend mail";
            }
            if(Str::emptyStrings([$data['error']])) {
                $newToken = Utils::randToken();
                $linkTag = "<a href='".URLROOT."/user/verify-email/$newToken"."'>Verify</a>";
                $body = "Your Verification Link is: $linkTag. Please ignore this mail if it wasnt you";
                $mailStatus = $this->mailModel->sendMail($email, 'New Verification Link', $body);
                if($this->userModel->insertNewEmailToken($email, $newToken) && $mailStatus) {
                    $this->userModel->deleteOldEmailTokens($email, $newToken);
                    Session::flash('email_token_sent', 'Check Email (and spam) For new verification link');
                    Server::redirect('user/login');
                }   else {
                    $data['error'] = "Error Encountered";
                }
            }
        }
        $this->view('user/resend-verification', $data);
    }
public function resendVerification ( ) : void { $ data [ 'error' ] = '' ; $ data [ 'default_mail' ] = $ _GET [ 'email' ] ?? '' ; if ( Server :: checkPostReq ( [ 'email' ] ) ) { $ email = $ _POST [ 'email' ] ; $ lastIssued = strtotime ( $ this -> userModel -> checkVerificationRequestTime ( $ email ) ) ; if ( ! $ this -> userModel -> ifEmailExists ( $ email ) ) { $ data [ 'error' ] = " Email not found " ; } else if ( $ this -> userModel -> isVerifiedEmail ( $ email ) ) { $ data [ 'error' ] = " Email already verified " ; } else if ( time ( ) - $ lastIssued < 600 ) { $ data [ 'error' ] = " Please wait 10 minutes to resend mail " ; } if ( Str :: emptyStrings ( [ $ data [ 'error' ] ] ) ) { $ newToken = Utils :: randToken ( ) ; $ linkTag = " <a href=' " . URLROOT . " /user/verify-email/ $ newToken " . " '>Verify</a> " ; $ body = " Your Verification Link is:  $ linkTag . Please ignore this mail if it wasnt you " ; $ mailStatus = $ this -> mailModel -> sendMail ( $ email , 'New Verification Link' , $ body ) ; if ( $ this -> userModel -> insertNewEmailToken ( $ email , $ newToken ) && $ mailStatus ) { $ this -> userModel -> deleteOldEmailTokens ( $ email , $ newToken ) ; Session :: flash ( 'email_token_sent' , 'Check Email (and spam) For new verification link' ) ; Server :: redirect ( 'user/login' ) ; } else { $ data [ 'error' ] = " Error Encountered " ; } } } $ this -> view ( 'user/resend-verification' , $ data ) ; }
Resend verification for unverified emails
 Allow after 10 minutes of last request
 Add new token to database
 Resend email for verification
Resend verification for unverified emails Allow after 10 minutes of last request Add new token to database Resend email for verification