2017-05-25 20:09:29 +07:00
|
|
|
|
|
|
|
import BluebirdPromise = require("bluebird");
|
|
|
|
import express = require("express");
|
|
|
|
import objectPath = require("object-path");
|
|
|
|
import FirstFactorValidator = require("./FirstFactorValidator");
|
2017-10-18 04:24:02 +07:00
|
|
|
import AuthenticationSessionHandler = require("./AuthenticationSession");
|
|
|
|
import { IRequestLogger } from "./logging/IRequestLogger";
|
2017-05-25 20:09:29 +07:00
|
|
|
|
2017-10-18 04:24:02 +07:00
|
|
|
export function validate(req: express.Request, logger: IRequestLogger): BluebirdPromise<void> {
|
|
|
|
return FirstFactorValidator.validate(req, logger)
|
2017-05-25 20:09:29 +07:00
|
|
|
.then(function () {
|
2017-10-18 04:24:02 +07:00
|
|
|
return AuthenticationSessionHandler.get(req, logger);
|
2017-09-22 03:07:34 +07:00
|
|
|
})
|
2017-10-18 04:24:02 +07:00
|
|
|
.then(function (authSession) {
|
2017-05-25 20:09:29 +07:00
|
|
|
if (!authSession.second_factor)
|
2017-09-22 03:07:34 +07:00
|
|
|
return BluebirdPromise.reject("No second factor variable.");
|
2017-05-25 20:09:29 +07:00
|
|
|
return BluebirdPromise.resolve();
|
|
|
|
});
|
|
|
|
}
|