public IHttpActionResult Post([FromBody] PassCodeModel p) { var identity = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identity.Claims; //string userId = User.Identity.GetUserId(); PassCodeModel n = p; TOTP t = new TOTP(p.imei, 300); bool x = false; x = t.verify(n.passcode); if (x) { return(Ok(new PassBackModel() { message = "Verified" })); } else { return(BadRequest("Invalid passcode")); } }
public ActionResult Index(PassCodeModel Model, string responseId, string ReturnUrl) { //parse and get the responseId responseId = GetResponseId(ReturnUrl); Common.DTO.SurveyAnswerDTO R = _isurveyFacade.GetSurveyAnswerResponse(responseId).SurveyResponseList[0]; Session["RootFormId"] = R.SurveyId.ToString(); Session["RootResponseId"] = responseId; // Get Last Page visited else send to page 1 - Begin XDocument Xdoc = XDocument.Parse(R.XML); int PageNumber = 0; if (Xdoc.Root.Attribute("LastPageVisited") != null) { if (!int.TryParse(Xdoc.Root.Attribute("LastPageVisited").Value, out PageNumber)) { PageNumber = 1; } } else { PageNumber = 1; } //if (ReturnUrl.EndsWith("/")) //{ // ReturnUrl = ReturnUrl + PageNumber.ToString(); //} //else //{ // ReturnUrl = ReturnUrl + "/" + PageNumber.ToString(); //} // Get Last Page visited else send to page 1 - End //get the surveyId string SurveyId = R.SurveyId; //put surveyId in viewbag so can be retrieved in Login/Index.cshtml ViewBag.SurveyId = SurveyId; Epi.Web.Common.Message.UserAuthenticationResponse result = _isurveyFacade.ValidateUser(responseId, Model.PassCode); if (result.UserIsValid) { FormsAuthentication.SetAuthCookie(Model.PassCode, false); // return RedirectToRoute(new { Controller = "Survey", Action = "Index", responseid = responseId }); return(Redirect(ReturnUrl)); } else { ModelState.AddModelError("", "Pass code is incorrect."); return(View()); } }