mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
use query to search user
This commit is contained in:
parent
255e6968c0
commit
8ab88f589e
@ -185,7 +185,12 @@ export default class Server {
|
|||||||
passwordField: "password",
|
passwordField: "password",
|
||||||
session: false
|
session: false
|
||||||
}, (username, password, done) => {
|
}, (username, password, done) => {
|
||||||
User.findOne({ username }).select("+password")
|
// check if username is a email with regex
|
||||||
|
let isEmail = username.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)
|
||||||
|
|
||||||
|
let query = isEmail ? { email: username } : { username: username }
|
||||||
|
|
||||||
|
User.findOne(query).select("+password")
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data === null) {
|
if (data === null) {
|
||||||
return done(null, false, this.options.jwtStrategy)
|
return done(null, false, this.options.jwtStrategy)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user