Example #1
0
        internal void OnLoginMessage(MessageEventArgs <LoginMessage> e)
        {
            var login = e.Message;

            if (login.Username.IsNullOrWhitespace())
            {
                e.Connection.SendAsync(new LoginResultMessage(new LoginResult(0, LoginResultState.FailedUsername)));
                return;
            }

            LoginResult result = this.context.UserProvider.Login(login.Username, login.Password);

            e.Connection.SendAsync(new LoginResultMessage(result));

            if (result.Succeeded)
            {
                Manager.Login(e.Connection, new UserInfo(login.Username, result.UserId, this.context.ChannelsProvider.DefaultChannel.ChannelId, false));
                e.Connection.SendAsync(new PermissionsMessage(result.UserId, this.context.PermissionsProvider.GetPermissions(result.UserId)));
            }
        }
 public void LoginNull()
 {
     Assert.Throws <ArgumentNullException> (() => manager.Login(null, user));
     Assert.Throws <ArgumentNullException> (() => manager.Login(server, null));
 }