Ejemplo n.º 1
0
        public User Create(User user, string password)
        {
            // validation
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new AppException("Password is required");
            }

            if (_context.Users.Any(x => x.Username == user.Username))
            {
                throw new AppException("Username \"" + user.Username + "\" is already taken");
            }

            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(password, out passwordHash, out passwordSalt);

            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;

            _context.Users.Add(user);
            _context.SaveChanges();

            return(user);
        }
Ejemplo n.º 2
0
        public Plugin Post([FromBody] string repoUrl)
        {
            var user = _nebulaContext.Users.FirstOrDefault(u => u.Id == Guid.Parse(User.Identity.Name));

            if (user != null)
            {
                _registryService.User = user;
            }

            var plugin = _registryService.ImportPlugin(repoUrl);

            _nebulaContext.Plugins.Add(plugin);
            _nebulaContext.SaveChanges();

            return(plugin);
        }
Ejemplo n.º 3
0
        public Template Post([FromBody] string repoUrl)
        {
            var user = _nebulaContext.Users.FirstOrDefault(u => u.Username == User.Identity.Name);

            if (user != null)
            {
                _registryService.User = user;
            }

            var template = _registryService.ImportTemplate(repoUrl);

            try
            {
                _registryService.VerifyTemplate(template);
                _nebulaContext.Templates.Add(template);
                _nebulaContext.SaveChanges();
            }
            catch (System.Exception)
            {
                throw;
            }

            return(template);
        }