当前位置: 首页>>代码示例>>C#>>正文


C# IAccountService.GetUser方法代码示例

本文整理汇总了C#中IAccountService.GetUser方法的典型用法代码示例。如果您正苦于以下问题:C# IAccountService.GetUser方法的具体用法?C# IAccountService.GetUser怎么用?C# IAccountService.GetUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAccountService的用法示例。


在下文中一共展示了IAccountService.GetUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetUser

        /// <summary>
        /// This method has been implemented so as we can refactor the entire application to use the Infostructure.SimpleList.Web.Service.Api class, which takes a userName and password parameter for every call.
        /// This method returns the User object for an authenticated user, whether they have come in through the service or the web front-end.
        /// There is still a bit of a "smell" about this method and some of the authetication architecture, in particular that I'm passing around unencrypted passwords, but it's tollerable for the time being.
        /// Since the API service is accessed directly, there should be no need to use this method where the user is not ASP.NET authenticated.
        /// </summary>
        /// <returns>A Infostructure.MyBigBro.DataModel.Models.User instance if authetication is successful.</returns>
        private Infostructure.MyBigBro.DataModel.Models.User GetUser(IAccountService accountService)
        {
            // Get the username and password off the query string, if they're there.
            ICredentials credentials = new Credentials
                                           {
                                               UserName = HttpContext.Current.Request.QueryString["userName"],
                                               Password = HttpContext.Current.Request.QueryString["password"]
                                           };

            // This is where we would go if we've come in via the service.
            if (credentials.UserName != null && credentials.Password != null)
                return accountService.ValidateUser(credentials);
            // This is where we go if we've come in via the web front-end, since the request will not be ASP.NET authenticated by the service.
            else if (HttpContext.Current.User.Identity.IsAuthenticated)
                return accountService.GetUser(HttpContext.Current.User.Identity.Name);
            // User has not been successfully authenticated.
            else
                return null;
        }
开发者ID:bernardoleary,项目名称:MyBigBro,代码行数:26,代码来源:SimpleAuthExtensions.cs


注:本文中的IAccountService.GetUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。