More preparations for 2 factor authentication
This commit is contained in:
@ -21,11 +21,11 @@ export function GetUserMiddleware(json = false, special_token: boolean = false,
|
||||
}
|
||||
try {
|
||||
let { login, special } = req.cookies
|
||||
|
||||
if (!login) invalid()
|
||||
|
||||
let token = await LoginToken.findOne({ token: login, valid: true })
|
||||
if (!token) invalid()
|
||||
if (!token.validated) invalid();
|
||||
|
||||
let user = await User.findById(token.user);
|
||||
if (!user) {
|
||||
@ -43,7 +43,7 @@ export function GetUserMiddleware(json = false, special_token: boolean = false,
|
||||
if (special) {
|
||||
Logging.debug("Special found")
|
||||
let st = await LoginToken.findOne({ token: special, special: true, valid: true })
|
||||
if (st && st.valid && st.user.toHexString() === token.user.toHexString()) {
|
||||
if (st && st.validated && st.valid && st.user.toHexString() === token.user.toHexString()) {
|
||||
if (st.validTill.getTime() < new Date().getTime()) { //Token expired
|
||||
Logging.debug("Special expired")
|
||||
st.valid = false;
|
||||
|
Reference in New Issue
Block a user