Пример #1
0
        public ActionResult AuthKey(int id, string key, string code)
        {
            var ctx = new DataAccess.SirCoNominaDataContext();
            var emp = ctx.Empleados.Where(i => i.idempleado == id).Single();

            byte[] secretKey = Base32Encoder.Decode(key);

            long timeStepMatched = 0;
            var  otp             = new Totp(secretKey);

            if (otp.VerifyTotp(code, out timeStepMatched, new VerificationWindow(2, 2)))
            {
                emp.authkey = key;
                ctx.SaveChanges();

                return(Content("SUCCESS"));
            }

            return(Content("FAILED"));
        }