Beispiel #1
0
        public IHttpActionResult create([FromBody] DBUser user)
        {
            UserService us = new UserService(User, ctx);
            us.User = user;

               return Json(us.Create());
        }
Beispiel #2
0
        public IHttpActionResult save( [FromBody] DBUser user)
        {
            UserService us = new UserService(User, ctx);
              us.Update(user);

              return Json(user);
        }
        public async Task<IHttpActionResult> profile()
        {


            if (!Request.Content.IsMimeMultipartContent())
            {
                return StatusCode(HttpStatusCode.UnsupportedMediaType);
            }

            var filesReadToProvider = await Request.Content.ReadAsMultipartAsync();
            UserService us = new UserService(new CTX());
            foreach (var stream in filesReadToProvider.Contents)
            {
                byte[] fileBytes = await stream.ReadAsByteArrayAsync();
       
               
                us.User.picture = Convert.ToBase64String(fileBytes);


                us.Update(us.User);
               
            }

            return Json(us.GetPicture());

        }
Beispiel #4
0
        IActionResult IUserController.save( [FromBody] DBUser user)
        {


          UserService us = new UserService( ctx);
          us.Update(user);

          return Json(user);

        }
Beispiel #5
0
        IActionResult IUserController.Picture()
        {


            UserService us = new UserService( ctx);

           

            return Json(us.GetPicture());

        }
Beispiel #6
0
        IActionResult IUserController.create([FromBody] DBUser user)
        {


            UserService us = new UserService( ctx);
            us.User = user;

           
           return Json(us.Create());
            


        }
Beispiel #7
0
        public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            UserService us = new UserService(null, new CTX());
            if (us.IsValidUser(context.UserName,context.Password) != null)
            {
                var profile = JsonConvert.SerializeObject(new SEAM.ViewModels.User(us.User));
                context.OwinContext.Set("tm:username", us.User.username);
                context.OwinContext.Set("tm:profile", profile);
                var client_id = context.OwinContext.Get<string>("tm:client_id");

                var identity = new ClaimsIdentity(context.Options.AuthenticationType);

                string username = string.Empty;

                if (us.User.authtype == "Form")
                {

                    username = context.UserName;
                }
                else {

                    username = us.User.username;

                }
                identity.AddClaim(new Claim(ClaimTypes.Name, username));
                identity.AddClaim(new Claim(ClaimTypes.Role, "user"));
                identity.AddClaim(new Claim("profile", profile));

                var props = new AuthenticationProperties(new Dictionary<string, string>
                {
                    {
                        "client_id", (client_id == null) ? string.Empty :client_id
                    },
                    {
                        "userName",username
                    }
                });

                var ticket = new AuthenticationTicket(identity, props);
                context.Validated(ticket);
            }
            return Task.FromResult(0);
        }
Beispiel #8
0
        public IHttpActionResult Picture()
        {
            UserService us = new UserService(User, ctx);

            return Json(us.GetPicture());
        }
Beispiel #9
0
 public IHttpActionResult Get()
 {
     UserService us = new UserService(User, ctx);
     ViewModels.User u = new ViewModels.User(us.User);
     return Json(u);
 }
Beispiel #10
0
        public AuthProvider(ICTX _ctx)
        {
            ctx = _ctx;
            us = new UserService(_ctx);

        }
Beispiel #11
0
        IActionResult IUserController.Get()
        {

            UserService us = new UserService(ctx);
            return Json(new VMUser(us.User));
        }