Example #1
0
        public PartialViewResult ProfileInfo(string name = "xxxxx", int age = 12, bool married = false)
        {
            var m = new Service.UserService().getUserSelfProfile(IdentityExtensions.GetUserId(User.Identity));


            return(PartialView("PP/_profile", m));
        }
        public DefaultSecurityManager(IHttpContextAccessor accessor, Service.UserService userService)
        {
            this.HttpContext = accessor.HttpContext;
            this.UserService = userService;

            this.InitToken();
            this.InitUser();
        }
Example #3
0
 /// <pdGenerated>default Remove</pdGenerated>
 public void RemoveUserService(Service.UserService oldUserService)
 {
     if (oldUserService == null)
     {
         return;
     }
     if (this.userService != null)
     {
         if (this.userService.Contains(oldUserService))
         {
             this.userService.Remove(oldUserService);
         }
     }
 }
Example #4
0
 /// <pdGenerated>default Add</pdGenerated>
 public void AddUserService(Service.UserService newUserService)
 {
     if (newUserService == null)
     {
         return;
     }
     if (this.userService == null)
     {
         this.userService = new System.Collections.ArrayList();
     }
     if (!this.userService.Contains(newUserService))
     {
         this.userService.Add(newUserService);
     }
 }
        public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            return(Task.Factory.StartNew(() =>
            {
                var username = context.UserName;
                var password = context.Password;
                Service.UserService userService = new Service.UserService();

                Models.User user = userService.GetUserByCredentials(username, password);

                if (user == null)
                {
                    context.SetError("invalid:grant", "Error");
                }
                else
                {
                    //ClaimsIdentity userIdentity = new ClaimsIdentity(context.Options.AuthenticationType);

                    //userIdentity.AddClaim(new Claim(ClaimTypes.Name, user.Name));
                    //userIdentity.AddClaim(new Claim("UserID", user.Id.ToString()));

                    //context.Validated(userIdentity);


                    var claims = new List <Claim>()
                    {
                        new Claim(ClaimTypes.Name, user.Name),
                        new Claim("UserID", user.Id.ToString()) //para encotrar el UserID en otra instancia se usa la extension OwinContextExtentions
                    };

                    ClaimsIdentity oautIdentity = new ClaimsIdentity(claims, context.Options.AuthenticationType);
                    context.Validated(new AuthenticationTicket(oautIdentity, new AuthenticationProperties()));

                    //IOwinContext ctx = context.OwinContext;
                    //var ID = ctx.GetUserId();
                }
            }));
        }
Example #6
0
 public ControllerBase()
 {
     UserService  = new Service.UserService();
     BlockService = new Service.BlockService();
     BlogService  = new Service.BlogService();
 }
Example #7
0
 public void Setup()
 {
     service = new Service.UserService();
 }
Example #8
0
 public ControllerBase()
 {
     UserService = new Service.UserService();
     BlockService = new Service.BlockService();
     BlogService = new Service.BlogService();
 }