Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate OTP #8

Closed
rezakiamanesh opened this issue Nov 5, 2022 · 1 comment
Closed

Validate OTP #8

rezakiamanesh opened this issue Nov 5, 2022 · 1 comment

Comments

@rezakiamanesh
Copy link

rezakiamanesh commented Nov 5, 2022

Hi dear friend @mohammad-fouladgar @50bhan @MizouziE
I used the package that you took pains to write and came across the following things that I think are bugs and it is very important.

The first thing is that in the config:
token_length and token_lifetime are set to OTP_TOKEN_LENGTH, which should be separate

The second case is in the approval of the OTP use code :
I have set the token_lifetime parameter to 2 minutes and it is stored correctly in the database, but when validating it, it allows login even though its time has expired.

public function verifyOtp()
    {
        try {
            $user= OTP()->useProvider('users')->validate($this->mobile,$this->token);
            Auth::loginUsingId($user->id);
            $this->emit('showAlert','ورود موفق');
            return  redirect()->route('panel.dashboard.index');
        } catch (InvalidOTPTokenException $exception){
            $this->emit('showAlert',"توکن منقضی شده یا نامعتبر است.",'متاسفیم','error');
            $this->emit('verfiyOtp',['mobile' => $this->mobile]);
        } catch (Throwable $ex) {
            $this->emit('showAlert', 'کد وارد شده صحیح نمیباشد','متاسفیم!','error');
            $this->emit('verfiyOtp',['mobile' => $this->mobile]);
        }
    }

I use livewire and that's why I used this method
Because OTPService could not be defined in the mount method.

@mohammad-fouladgar
Copy link
Owner

Hi @rezakiamanesh . Thank you for reporting this issue. I fixed that.
Now, you can use and test the latest version v3.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants