Beispiel #1
0
        /// <summary>Returns the user associated with this login</summary>
        /// <param name="login">用户登录信息</param>
        /// <returns>返回查询到的用户</returns>
        public Task <TUser> FindAsync(UserLoginInfo login, CancellationToken cancellationToken)
        {
            if (login == null)
            {
                throw new ArgumentNullException("login");
            }


            return(TaskHelper.RunTask(() =>
            {
                var userId = _objectStorage.FindOneByCondition <UserLogins>(p => p.LoginProvider == login.LoginProvider && p.ProviderKey == login.ProviderKey).UserId;
                if (userId != ObjectId.Empty)
                {
                    var user = _objectStorage.FindById <TUser>(userId.ToString());
                    if (user != null)
                    {
                        return user;
                    }
                }

                return default(TUser);
            }));
        }
Beispiel #2
0
 public Task <TRole> FindByNameAsync(string normalizedRoleName, CancellationToken cancellationToken)
 {
     return(TaskHelper.RunTask(() =>
                               _objectStorage.FindOneByCondition <TRole>(p => p.NormalizedName == normalizedRoleName)));
 }