예제 #1
0
        public LoginResponse CompleteMultiFactorLogin([FromBody] MultifactorLoginRequest request)
        {
            var session = OpContext.OpenSession();
            var process = GetMutiFactorProcess(session, request.ProcessToken);

            OpContext.ThrowIfNull(process, ClientFaultCodes.ObjectNotFound, "processToken", "Login process not found or expired.");
            OpContext.ThrowIf(process.PendingFactors != ExtraFactorTypes.None, ClientFaultCodes.InvalidValue, "PendingFactors",
                              "Multi-factor login process not completed, verification pending: {0}.", process.PendingFactors);
            var login = process.Login;

            var loginService = OpContext.App.GetService <ILoginService>();
            var loginResult  = loginService.CompleteMultiFactorLogin(OpContext, login);
            var displayName  = OpContext.App.GetUserDispalyName(OpContext.User);

            session.SaveChanges();
            return(new LoginResponse()
            {
                Status = LoginAttemptStatus.Success, SessionId = loginResult.SessionId,
                UserName = login.UserName, UserDisplayName = displayName,
                UserId = login.UserId, AltUserId = login.AltUserId, LoginId = login.Id,
                PasswordExpiresDays = login.GetExpiresDays(), Actions = loginResult.Actions,
                LastLoggedInOn = loginResult.PreviousLoginOn,
                AuthenticationToken = CreateAuthToken()
            });
        }//method
예제 #2
0
        public LoginResponse CompleteMultiFactorLogin(MultifactorLoginRequest request)
        {
            var process = GetMutiFactorProcess(request.ProcessToken);

            Context.ThrowIfNull(process, ClientFaultCodes.ObjectNotFound, "processToken", "Login process not found or expired.");
            Context.ThrowIf(process.PendingFactors != ExtraFactorTypes.None, ClientFaultCodes.InvalidValue, "PendingFactors",
                            "Multi-factor login process not completed, verification pending: {0}.", process.PendingFactors);
            var login       = process.Login;
            var loginResult = _loginService.CompleteMultiFactorLogin(Context, login, request.Expiration);
            var displayName = Context.App.GetUserDispalyName(Context.User);

            return(new LoginResponse()
            {
                Status = LoginAttemptStatus.Success, AuthenticationToken = loginResult.SessionToken,
                UserName = login.UserName, UserDisplayName = displayName,
                UserId = login.UserId, AltUserId = login.AltUserId, LoginId = login.Id,
                PasswordExpiresDays = login.GetExpiresDays(), Actions = loginResult.Actions, LastLoggedInOn = loginResult.LastLoggedInOn
            });
        }//method