public OktaMembershipUser OktaUserToOktaMembershipUser(User oktaUser, bool populateApps = true)
        {
            bool isApproved  = false;
            bool isLockedOut = false;
            var  status      = oktaUser.Status;

            if (status == "ACTIVE")
            {
                isApproved = true;
            }
            if (status == "PASSWORD_EXPIRED" | status == "LOCKED_OUT" | status == "RECOVERY")
            {
                isLockedOut = true;
            }
            DateTime lastLockoutDate  = new DateTime(1754, 1, 1);
            string   passwordQuestion = "";

            if (oktaUser.Credentials.RecoveryQuestion.Answer != null)
            {
                passwordQuestion = oktaUser.Credentials.RecoveryQuestion.Answer;
            }
            OktaMembershipUser user = new OktaMembershipUser(
                Membership.Provider.Name.ToString(),
                oktaUser.Profile.Login,
                oktaUser.Id,
                oktaUser.Profile.Email,
                passwordQuestion,
                "", // "comment" - Okta doesn't have this concept by default
                isApproved,
                isLockedOut,
                oktaUser.Created,
                oktaUser.LastLogin,
                oktaUser.LastUpdated,
                oktaUser.PasswordChanged,
                lastLockoutDate
                );

            if (!populateApps)
            {
                return(user);
            }

            var userAppLinks = users.GetUserAppLinksClient(oktaUser);
            var appLinks     = userAppLinks.ToList <AppLink>();

            user.apps = from link in appLinks select new OktaAppLink(link);

            user.FirstName   = oktaUser.Profile.FirstName;
            user.LastName    = oktaUser.Profile.LastName;
            user.PhoneNumber = oktaUser.Profile.MobilePhone;

            return(user);
        }
        // The following methods are not implemented since they are not used by the MVC Music Store:
        // - CreateUser
        // - GetUser(object providerUserKey, bool userIsOnline)

        /// <summary>
        /// Returns a MembershipUser object representation of the user identified by "username".
        ///
        /// See also: http://msdn.microsoft.com/en-us/library/gg538376%28v=vs.111%29.aspx
        /// </summary>
        /// <param name="username">The user name to return the user object for</param>
        /// <param name="userIsOnline">(Unused) Intended to be used to signal that the "last-activity" timestamp for the user should be updated.</param>
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            OktaMembershipUser user = okta.GetOktaMembershipUser(username);

            return(user);
        }
        public OktaMembershipUser OktaUserToOktaMembershipUser(User oktaUser, bool populateApps = true)
        {
            bool isApproved = false;
            bool isLockedOut = false;
            var status = oktaUser.Status;
            if (status == "ACTIVE")
            {
                isApproved = true;
            }
            if (status == "PASSWORD_EXPIRED" | status == "LOCKED_OUT" | status == "RECOVERY")
            {
                isLockedOut = true;
            }
            DateTime lastLockoutDate = new DateTime(1754, 1, 1);
            string passwordQuestion = "";
            if (oktaUser.Credentials.RecoveryQuestion.Answer != null)
            {
                passwordQuestion = oktaUser.Credentials.RecoveryQuestion.Answer;
            }
            OktaMembershipUser user = new OktaMembershipUser(
                Membership.Provider.Name.ToString(),
                oktaUser.Profile.Login,
                oktaUser.Id,
                oktaUser.Profile.Email,
                passwordQuestion,
                "", // "comment" - Okta doesn't have this concept by default
                isApproved,
                isLockedOut,
                oktaUser.Created,
                oktaUser.LastLogin,
                oktaUser.LastUpdated,
                oktaUser.PasswordChanged,
                lastLockoutDate
                );

            if(!populateApps) {
                return user;
            }

            var userAppLinks = users.GetUserAppLinksClient(oktaUser);
            var appLinks = userAppLinks.ToList<AppLink>();
            user.apps = from link in appLinks select new OktaAppLink(link);

            user.FirstName = oktaUser.Profile.FirstName;
            user.LastName = oktaUser.Profile.LastName;
            user.PhoneNumber = oktaUser.Profile.MobilePhone;

            return user;
        }