Exemple #1
0
        async Task <Tuple <bool, string> > ITerminalConnection.CreateUser(DatabaseUser user)
        {
            var tus = _database.GetUserByName(user.Username).Result;

            if (tus != null)
            {
                return(Tuple.Create(false, $"User {user.Username} already exists"));
            }

            _database.CreateUser(user).Wait();

            return(new Tuple <bool, string>(true, $"User {user.Username} created"));
        }
Exemple #2
0
        async Task <Tuple <bool, string, ServerInfo> > IConnection.DoLogin(string username, string password)
        {
            //check user

            var user = await _database.GetUserByName(username);

            if (user == null)
            {
                return(Tuple.Create <bool, string, ServerInfo>(false, $"User {username} not found", null));
            }

            if (user.Password != password)
            {
                return(Tuple.Create <bool, string, ServerInfo>(false, $"Wrong password for user {username}", null));
            }


            ServerInfo info = new ServerInfo();

            info.AdditionalRegisteredBehaviours = TYPEBEHAVIOUR.AdditionalBehaviours;


            return(Tuple.Create(true, "TestServer", info));
        }