コード例 #1
0
 public GenericPrincipal GetByRefreshToken(string refresh_token)
 {
     using (var obj = new AspNetUsersBusiness())
     {
         var user = obj.GetByRefreshToken(refresh_token);
         if (user != null)
         {
             var identity = new AuthenticationIdentity(user.User.Username);
             identity.AddClaim(new Claim("Id", user.Userid.ToString()));
             identity.AddClaim(new Claim("Modulo", "0"));
             identity.AddClaim(new Claim(ClaimTypes.Name, user.User.Username));
             return(new GenericPrincipal(identity, null));;
         }
         return(null);
     }
 }
コード例 #2
0
        public ClaimsIdentity GetUserByUserName(string username)
        {
            using (var obj = new AspNetUsersBusiness()) {
                var user = obj.GetUserByName(username);

                if (user != null)
                {
                    var identity = new ClaimsIdentity("OAuthBearer");
                    identity.AddClaim(new Claim("Id", user.Id.ToString()));
                    identity.AddClaim(new Claim(ClaimTypes.Name, user.Username));
                    identity.AddClaim(new Claim("Modulo", "0"));
                    return(identity);
                }
                return(null);
            };
        }