Welcome Guest, Not a member yet? Register   Sign In
Creating SMS OTP Using Shield
#1
Sad 
(This post was last modified: 11-13-2024, 07:22 PM by vishwajithkeshan2.)

Hi,
I'm trying to build a function to send SMS for two-factor authentication (2FA) instead of using email for 2FA. However, I got stuck trying to override the existing authentication handler function, which creates a 6-digit code and sends it to the user's email address. I want to create a new function to replace that. I'm using CI4 + Shield
Reply
#2

(This post was last modified: 11-14-2024, 03:08 AM by captain-sensible.)

i create a random 5  numbers , which i  leverage to show images for captcha like this:

Code:
    public function login()
        {
        //        session_start();
        $session = \Config\Services::session();
        $myarray = array( chr(rand(48,57)) , chr(rand(48,57)) , chr(rand(48,57)) , chr(rand(48,57)) , chr(rand(48,57)));
        $_SESSION['captcha']= $myarray;            
              
                $data = [
                'title'  => 'login  page',
                 'captcha'=>$myarray,
                 'date'=>$this->myDate
            
            ];

        
        echo view('usrLogin',$data);
        
    
                                            
                                            
        }


i then check to see if what was show to prospective admin logging in like this:


Code:
public function credentials()

{
    $session = \Config\Services::session();
    $theArray= $_SESSION['captcha'];
    $this->actualCaptcha= implode("",$theArray);
$this->captcha= $this->request->getVar('captcha');
// if above two lines equate to same thing then captcha entered correctly

not exactly what you want but maybe give you an approach based on producing a number then checking
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Github  
Reply
#3

Please refer to the link below:

https://github.com/codeigniter4/shield/d...t-11248988
Reply




Theme © iAndrew 2016 - Forum software by © MyBB