public bool SubmitPin(Guid factorId, string pin)
        {
            OpContext.ThrowIfEmpty(pin, ClientFaultCodes.ValueMissing, "pin", "Pin value missing");
            var session = OpenSession();
            var login   = GetCurrentLogin(session);
            var factor  = login.ExtraFactors.FirstOrDefault(f => f.Id == factorId);

            OpContext.ThrowIfNull(factor, ClientFaultCodes.ObjectNotFound, "factor", "Factor not found, ID: {0}", factorId);
            var processService = OpContext.App.GetService <ILoginProcessService>();
            var processes      = processService.GetActiveConfirmationProcesses(factor, LoginProcessType.FactorVerification);

            OpContext.ThrowIf(processes.Count == 0, ClientFaultCodes.ObjectNotFound, "LoginProcess", "Confirmation process not found or expired.");
            try {
                foreach (var process in processes)
                {
                    if (processService.SubmitPin(process, pin))
                    {
                        return(true);
                    }
                }
                return(false);
            } finally {
                session.SaveChanges();
            }
        }
Beispiel #2
0
        public void VerifyPin([FromBody] VerifyPinRequest request)
        {
            var session = OpContext.OpenSession();
            var process = GetActiveProcess(session, request.ProcessToken, confirmedOnly: false);

            OpContext.ThrowIfEmpty(request.Pin, ClientFaultCodes.ValueMissing, "pin", "Pin value missing");
            if (process != null)
            {
                ProcessService.SubmitPin(process, request.Pin);
            }
        }
Beispiel #3
0
        private ILoginProcess GetMutiFactorProcess(IEntitySession session, string token, bool throwIfNotFound = true)
        {
            OpContext.ThrowIfEmpty(token, ClientFaultCodes.ValueMissing, "token", "Process token may not be empty.");
            var processService = OpContext.App.GetService <ILoginProcessService>();
            var process        = processService.GetActiveProcess(session, LoginProcessType.MultiFactorLogin, token);

            if (throwIfNotFound)
            {
                OpContext.ThrowIfNull(process, ClientFaultCodes.ObjectNotFound, "LoginProcess", "Invalid login process token - process not found or expired.");
            }
            return(process);
        }
Beispiel #4
0
        public bool VerifyPinForMultiFactor([FromBody] VerifyPinRequest request)
        {
            var session = OpContext.OpenSession();
            var process = GetMutiFactorProcess(session, request.ProcessToken);

            OpContext.ThrowIfNull(process, ClientFaultCodes.ObjectNotFound, "Process", "Process not found or expired.");
            OpContext.ThrowIfEmpty(request.Pin, ClientFaultCodes.ValueMissing, "Pin", "Pin value missing.");
            var processService = OpContext.App.GetService <ILoginProcessService>();
            var result         = processService.SubmitPin(process, request.Pin);

            session.SaveChanges();
            return(result);
        }
Beispiel #5
0
        public bool VerifyEmailPin(string processToken, string pin)
        {
            OpContext.ThrowIfEmpty(processToken, ClientFaultCodes.ValueMissing, "processToken", "ProcessToken value missing");
            OpContext.ThrowIfEmpty(pin, ClientFaultCodes.ValueMissing, "pin", "Pin value missing");
            var session        = OpContext.OpenSession();
            var processService = OpContext.App.GetService <ILoginProcessService>();
            var process        = processService.GetActiveProcess(session, LoginProcessType.FactorVerification, processToken);

            OpContext.ThrowIfNull(process, ClientFaultCodes.ObjectNotFound, "processToken", "Login process not found or expired.");
            var result = processService.SubmitPin(process, pin);

            session.SaveChanges();
            return(result);
        }