public async Task <Account> GetAccount(string email)
        {
            var account = await _accountStore.GetAccount(email);

            account.Password = null;
            return(account);
        }
        public BankAccount GetAccount(int accountNumber, string password)
        {
            var account = store.GetAccount(accountNumber);

            account.Authenticate(password);
            return(account);
        }
Exemplo n.º 3
0
        public async Task <Account> GetAccount(User user, CancellationToken cancellationToken)
        {
            Ensure.Any.IsNotNull(user, nameof(user));

            var cachedAccount = _accountCache.GetAccount(user.Username);

            if (cachedAccount != null)
            {
                return(cachedAccount);
            }

            var parsedAccount = new Account(user.Username);

            var account = await _accountStore.GetAccount(parsedAccount.Provider, parsedAccount.Subject, cancellationToken).ConfigureAwait(false);

            if (account.IsNewAccount)
            {
                // This account has just been created
                var profile = await CreateProfile(account.Id, user, cancellationToken).ConfigureAwait(false);

                _profileCache.StoreProfile(profile);
            }

            _accountCache.StoreAccount(account);

            return(account);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 判斷這個使用者是否已經通過了身分驗證
        /// </summary>
        /// <returns></returns>
        public static async Task <Account> IsAlreadyAuthenticated()
        {
            // 取得 Prism 相依性服務使用到的容器
            IUnityContainer fooContainer = (XFoAuth2.App.Current as PrismApplication).Container;
            // 取得 IAccountStore 介面實際實作的類別物件
            IAccountStore fooIAccountStore = fooContainer.Resolve <IAccountStore>();

            #region 若可以取得使用者認證的使用者資訊,表示,這個使用者已經通過認證了
            if (fooIAccountStore.GetPlatform() == "UWP")
            {
                return(await fooIAccountStore.GetAccount());
            }
            else
            {
                // Retrieve any stored account information
                var accounts = await AccountStore.Create().FindAccountsForServiceAsync(AppName);

                var account = accounts.FirstOrDefault();

                // If we already have the account info then we are set
                if (account == null)
                {
                    return(null);
                }
                return(account);
            }
            #endregion
        }
        public IList <AccountUser> SelectAccounts(long idActivityDefinition, IList <SelectorDefinition> selectors, RuleContext ruleContext)
        {
            IList <AccountUser> collected = new List <AccountUser>();

            foreach (SelectorDefinition selectorDefinition in selectors)
            {
                IList <RuleFilterDefinition> filters = _ruleStorePlugin.FindFiltersBySelectorId((long)selectorDefinition.Id);

                bool selectorMatch = true;
                foreach (RuleFilterDefinition ruleFilterDefinition in filters)
                {
                    string field      = ruleFilterDefinition.Field;
                    string operat     = ruleFilterDefinition.Operator;
                    string expression = ruleFilterDefinition.Expression;

                    bool result = false;
                    switch (operat)
                    {
                    case "=":
                        result = ruleContext[field].Equals(expression);
                        break;
                    }

                    if (!result)
                    {
                        selectorMatch = false;
                    }
                }

                if (selectorMatch)
                {
                    IAccountStore accountStore = _accountManager.GetStore();
                    ISet <string> accounts     = accountStore.GetAccountIds(selectorDefinition.GroupId);

                    foreach (string accountId in accounts)
                    {
                        AccountUser account = accountStore.GetAccount(accountId);
                        collected.Add(account);
                    }
                }
            }

            return(collected);
        }
Exemplo n.º 6
0
        public IList <AccountUser> SelectAccounts(IList <SelectorDefinition> selectors, IDictionary <int, List <RuleFilterDefinition> > dicFilters, RuleContext ruleContext)
        {
            IList <AccountUser>        collected         = new List <AccountUser>();
            IList <SelectorDefinition> matchingSelectors = FindMatchingSelectors(selectors, dicFilters, ruleContext);

            IAccountStore accountStore = _accountManager.GetStore();

            foreach (SelectorDefinition selectorDefinition in matchingSelectors)
            {
                ISet <string> accounts = accountStore.GetAccountIds(selectorDefinition.GroupId);
                foreach (string accountId in accounts)
                {
                    AccountUser account = accountStore.GetAccount(accountId);
                    collected.Add(account);
                }
            }

            return(collected);
        }