mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-12 03:54:16 +00:00
not decode password
username
on passport stratergy
This commit is contained in:
parent
3190fba4b7
commit
d498a03505
@ -1,3 +1,13 @@
|
|||||||
|
// patches
|
||||||
|
const { Buffer } = require("buffer")
|
||||||
|
|
||||||
|
global.b64Decode = (data) => {
|
||||||
|
return Buffer.from(data, "base64").toString("utf-8")
|
||||||
|
}
|
||||||
|
global.b64Encode = (data) => {
|
||||||
|
return Buffer.from(data, "utf-8").toString("base64")
|
||||||
|
}
|
||||||
|
|
||||||
Array.prototype.updateFromObjectKeys = function (obj) {
|
Array.prototype.updateFromObjectKeys = function (obj) {
|
||||||
this.forEach((value, index) => {
|
this.forEach((value, index) => {
|
||||||
if (obj[value] !== undefined) {
|
if (obj[value] !== undefined) {
|
||||||
@ -16,14 +26,6 @@ import passport from "passport"
|
|||||||
import { User, Session, Config } from "./models"
|
import { User, Session, Config } from "./models"
|
||||||
import jwt from "jsonwebtoken"
|
import jwt from "jsonwebtoken"
|
||||||
|
|
||||||
const { Buffer } = require("buffer")
|
|
||||||
const b64Decode = global.b64Decode = (data) => {
|
|
||||||
return Buffer.from(data, "base64").toString("utf-8")
|
|
||||||
}
|
|
||||||
const b64Encode = global.b64Encode = (data) => {
|
|
||||||
return Buffer.from(data, "utf-8").toString("base64")
|
|
||||||
}
|
|
||||||
|
|
||||||
const ExtractJwt = require("passport-jwt").ExtractJwt
|
const ExtractJwt = require("passport-jwt").ExtractJwt
|
||||||
const LocalStrategy = require("passport-local").Strategy
|
const LocalStrategy = require("passport-local").Strategy
|
||||||
|
|
||||||
@ -188,11 +190,11 @@ class Server {
|
|||||||
passwordField: "password",
|
passwordField: "password",
|
||||||
session: false
|
session: false
|
||||||
}, (username, password, done) => {
|
}, (username, password, done) => {
|
||||||
User.findOne({ username: b64Decode(username) }).select("+password")
|
User.findOne({ username }).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)
|
||||||
} else if (!bcrypt.compareSync(b64Decode(password), data.password)) {
|
} else if (!bcrypt.compareSync(password, data.password)) {
|
||||||
return done(null, false, this.options.jwtStrategy)
|
return done(null, false, this.options.jwtStrategy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user