Ejemplo n.º 1
0
        public override void Process(IXFireClient context)
        {
            var user = context.Server.Database.QueryUser(Username);

            if (user != null)
            {
                if (user.Password != Password)
                {
                    context.SendAndProcessMessage(new LoginFailure());
                    return;
                }
            }
            else
            {
                user = context.Server.Database.InsertUser(Username, Password, context.Salt);
            }

            // Remove any older sessions from this user (duplicate logins)
            context.RemoveDuplicatedSessions(user);

            context.User = user;

            var success = new LoginSuccess();

            context.SendAndProcessMessage(success);
        }
Ejemplo n.º 2
0
        public override async Task Process(IXFireClient context)
        {
            var user = await context.Server.Database.QueryUser(Username);

            if (user != null)
            {
                if (!BCrypt.Net.BCrypt.Verify(Password, user.Password))
                {
                    await context.SendAndProcessMessage(new LoginFailure());

                    return;
                }
            }
            else
            {
                var hashPassword = BCrypt.Net.BCrypt.HashPassword(Password);
                user = await context.Server.Database.InsertUser(Username, hashPassword, context.Salt);
            }

            // Remove any older sessions from this user (duplicate logins)
            context.RemoveDuplicatedSessions(user);

            context.User = user;

            var success = new LoginSuccess();
            await context.SendAndProcessMessage(success);
        }