tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.3k stars 1.54k forks source link

Laravel Jwt how to check if user email is verified? #1722

Open umairm638 opened 5 years ago

umairm638 commented 5 years ago

Subject of the issue

This is a question related to how I can add a custom check in authentication and return error message if failed.

Your environment

Q A
Bug? no
New Feature? no
Framework Laravel
PHP version 5.6

Steps to reproduce

I've a column in user table having info about user email verified or not. I need to allow user to login if verified else return error in APIs.

Expected behaviour

I want to add a custom check in it for checking verification column but I'm unable to find where I've to add that check. API URL is "/oauth/token" and I'm unable to find where it's code is written.

Actual behaviour

It allow users to login even if their emails are not verified.

haidang666 commented 5 years ago

You can write it in a new middleware or login function. Example before this in login function auth('api')->attempt($credentials)

umairm638 commented 5 years ago

@HaiDang666 thanks for your reply, actually my question is mainly that I'm unable to find that piece of code which is being used to check login. It's not coming inside 'authenticate' method.

Can you please tell if there is any default middleware or event or anything else in Laravel which is used by jwt-auth for this URL '/oauth/token' so that I can modify that code.

haidang666 commented 5 years ago

Could you post the code for that route