public Account Create(Account toRegister, string sourceToken)
        {
            var source = _accountSourceCoreController.GetByToken(sourceToken);

            if (string.IsNullOrWhiteSpace(toRegister.Name) || (source.RequiresPassword && string.IsNullOrWhiteSpace(toRegister.Password)))
            {
                throw new InvalidAccountDetailsException("Invalid username or password.");
            }

            var user = _userCoreController.GetExistingUser(toRegister.Name) ?? _userCoreController.Create(new User {
                Name = toRegister.Name
            });

            if (source.RequiresPassword)
            {
                toRegister.Password = PasswordEncryption.Encrypt(toRegister.Password);
            }

            var registered = _accountDbController.Create(new Account {
                Name            = toRegister.Name,
                Password        = toRegister.Password,
                AccountSourceId = source.Id,
                UserId          = user.Id,
                User            = user
            });

            _actorRoleController.Create(ClaimScope.Account, registered.UserId, registered.Id);

            _logger.LogInformation($"{registered.Id}");

            return(registered);
        }
Beispiel #2
0
        public Game Create(Game newGame, int creatorId, SUGARContext context = null)
        {
            newGame = _gameDbController.Create(newGame, context);
            _actorRoleController.Create(ClaimScope.Game, creatorId, newGame.Id, context);

            _logger.LogInformation($"Created: Game: {newGame.Id}, for CreatorId: {creatorId}");

            return(newGame);
        }
Beispiel #3
0
        public Role Create(Role newRole, int creatorId)
        {
            newRole = _roleDbController.Create(newRole);
            _actorRoleController.Create(ClaimScope.Role, creatorId, newRole.Id);

            _logger.LogInformation($"Role: {newRole.Id} for CreatorId: {creatorId}");

            return(newRole);
        }
        public User Create(User newUser, SUGARContext context = null)
        {
            newUser = _userController.Create(newUser, context);

            _actoRoleController.Create(ClaimScope.User, newUser.Id, newUser.Id, context);

            _logger.LogInformation($"{newUser.Id}");

            return newUser;
        }
Beispiel #5
0
 private void AssignController(int controllerId, int groupId)
 {
     _actorRoleController.Create(ClaimScope.Group, controllerId, groupId);
 }