/// <summary>
        /// Client passed login challenge and can be logged in
        /// </summary>
        /// <param name="client"></param>
        private static void LoginClient(IAuthClient client)
        {
            var acc = client.Account;

            if (acc == null)
            {
                //Resync accounts first
                AccountMgr.Instance.Resync();

                // Pass and username are identical so an Account can be auto-created
                // the corresponding check happened before
                s_log.Debug(resources.AutocreatingAccount, client.AccountName);

                if (AccountMgr.DoesAccountExist(client.AccountName))
                {
                    // account was already created
                    SendAuthProofErrorReply(client, AccountStatus.Failure);
                    return;
                }
                client.Account = acc = AutoCreateAccount(client);
            }

            var authInfo = new AuthenticationInfo
            {
                SessionKey        = client.Authenticator.SRP.SessionKey.GetBytes(40),
                Salt              = client.Authenticator.SRP.Salt.GetBytes(32),
                Verifier          = client.Authenticator.SRP.Verifier.GetBytes(),
                SystemInformation = ClientInformation.Serialize(client.Info)
            };

            client.Server.StoreAuthenticationInfo(client.AccountName, authInfo);

            acc.OnLogin(client);
            SendAuthProofSuccessReply(client);
        }
            public override void Process(CmdTrigger <AuthServerCmdArgs> trigger)
            {
                var name = trigger.Text.NextWord();

                //Resync accounts first
                AccountMgr.Instance.Resync();

                if (AccountMgr.DoesAccountExist(name))
                {
                    trigger.Reply("The account \"{0}\" already exists!", name);
                }
                else
                {
                    if (!AccountMgr.NameValidator(ref name))
                    {
                        trigger.Reply("Invalid Account-Name: " + name);
                        return;
                    }

                    var pw = trigger.Text.NextWord();

                    if (pw.Length == 0)
                    {
                        trigger.Reply("Password required.");
                    }
                    else
                    {
                        var      role  = trigger.Text.NextWord();
                        var      email = trigger.Text.NextWord();
                        ClientId clientId;
                        if (trigger.Text.HasNext)
                        {
                            clientId = trigger.Text.NextEnum((ClientId)int.MaxValue);
                            if (clientId == (ClientId)int.MaxValue)
                            {
                                trigger.Reply("Invalid ClientId specified - Choose either of: " +
                                              Enum.GetValues(typeof(ClientId)).OfType <object>().ToString(", "));
                            }
                        }
                        else
                        {
                            clientId = ClientId.Wotlk;
                        }

                        role = PrivilegeMgr.Instance.GetRoleOrDefault(role);

                        var acc = AccountMgr.Instance.CreateAccount(name, pw, email, role, clientId);

                        if (acc != null)
                        {
                            trigger.Reply("Account \"{0}\" created (Role: {1}, Email: {2}, ClientId: {3})",
                                          name,
                                          acc.RoleGroupName,
                                          acc.EmailAddress,
                                          clientId);
                        }
                        else
                        {
                            // cannot really happen
                            trigger.Reply("Failed to create Account \"{0}\"!", name);
                        }
                    }
                }
            }