public ILoginResult Login(string accountIdentifier, string inputPassword)
        {
            Query <AccountModel, string> query = new AccountQuery();

            query.Filter = new AccountQuery.UsernameFilter(accountIdentifier);

            var results = query.Execute().ToList();

            if (results != null && results.Count > 0)
            {
                AccountModel account = results[0];

                if (hashedPassword.VerifyPassword(inputPassword, account.Password))
                {
                    if (account.IsActive)
                    {
                        return(new LoginResult(new AccountData
                        {
                            Id = account.Identity,
                            Username = account.Username,
                            AccessType = account.AccessType,
                            IsActive = account.IsActive
                        }));
                    }
                    else
                    {
                        return(new LoginResult(string.Format("{0} is deactivated", account.Username)));
                    }
                }
                else
                {
                    return(new LoginResult(string.Format("Wrong password for {0}", account.Username)));
                }
            }
            else
            {
                return(new LoginResult("No accounts found with given username"));
            }
        }
Exemplo n.º 2
0
        public Account GetUserAccount(Guid userId, AccountType type)
        {
            var query = new AccountQuery(dbContext.Accounts);

            return(query.Execute(userId, type));
        }