コード例 #1
0
        public virtual async Task <ActionResult> ResetPassword(ResetPasswordFormViewModel model)
        {
            CheckModelState();

            _unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant);

            var userId = Convert.ToInt64(SimpleStringCipher.Decrypt(model.UserId));

            var user = await _userManager.GetUserByIdAsync(userId);

            if (user == null || user.PasswordResetCode.IsNullOrEmpty() || user.PasswordResetCode != model.ResetCode)
            {
                throw new UserFriendlyException(L("InvalidPasswordResetCode"), L("InvalidPasswordResetCode_Detail"));
            }

            user.Password          = new PasswordHasher().HashPassword(model.Password);
            user.PasswordResetCode = null;
            user.IsEmailConfirmed  = true;
            user.ShouldChangePasswordOnNextLogin = false;

            await _userManager.UpdateAsync(user);

            if (user.IsActive)
            {
                await SignInAsync(user);
            }

            return(RedirectToAction("Index", "Application"));
        }
コード例 #2
0
        public virtual async Task <ActionResult> EmailConfirmation(EmailConfirmationViewModel model)
        {
            CheckModelState();

            _unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant);

            var userId = Convert.ToInt64(SimpleStringCipher.Decrypt(model.UserId));

            var user = await _userManager.GetUserByIdAsync(userId);

            if (user == null || user.EmailConfirmationCode.IsNullOrEmpty() || user.EmailConfirmationCode != model.ConfirmationCode)
            {
                throw new UserFriendlyException(L("InvalidEmailConfirmationCode"), L("InvalidEmailConfirmationCode_Detail"));
            }

            user.IsEmailConfirmed      = true;
            user.EmailConfirmationCode = null;

            await _userManager.UpdateAsync(user);

            var tenancyName = user.TenantId.HasValue
                ? (await _tenantManager.GetByIdAsync(user.TenantId.Value)).TenancyName
                : "";

            return(RedirectToAction(
                       "Login",
                       new
            {
                successMessage = L("YourEmailIsConfirmedMessage"),
                tenancyName = tenancyName,
                userNameOrEmailAddress = user.UserName
            }));
        }
コード例 #3
0
        public virtual async Task <ActionResult> ResetPassword(ResetPasswordFormViewModel model)
        {
            this.CheckModelState();
            IActiveUnitOfWork current = this._unitOfWorkManager.Current;

            current.DisableFilter(new string[] { "MayHaveTenant" });
            long num = Convert.ToInt64(SimpleStringCipher.Decrypt(model.UserId, "gsKnGZ041HLL4IM8"));

            FuelWerx.Authorization.Users.User userByIdAsync = await this._userManager.GetUserByIdAsync(num);

            if (userByIdAsync == null || userByIdAsync.PasswordResetCode.IsNullOrEmpty() || userByIdAsync.PasswordResetCode != model.ResetCode)
            {
                throw new UserFriendlyException(this.L("InvalidPasswordResetCode"), this.L("InvalidPasswordResetCode_Detail"));
            }
            userByIdAsync.Password          = (new PasswordHasher()).HashPassword(model.Password);
            userByIdAsync.PasswordResetCode = null;
            userByIdAsync.IsEmailConfirmed  = true;
            userByIdAsync.ShouldChangePasswordOnNextLogin = false;
            await this._userManager.UpdateAsync(userByIdAsync);

            if (userByIdAsync.IsActive)
            {
                await this.SignInAsync(userByIdAsync, null, false);
            }
            return(this.RedirectToAction("Index", "Application"));
        }
コード例 #4
0
        public virtual async Task <ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            Guid guid;
            Guid guid1;

            this.CheckModelState();
            IActiveUnitOfWork current = this._unitOfWorkManager.Current;

            current.DisableFilter(new string[] { "MayHaveTenant" });
            long num = Convert.ToInt64(SimpleStringCipher.Decrypt(model.UserId, "gsKnGZ041HLL4IM8"));

            FuelWerx.Authorization.Users.User userByIdAsync = await this._userManager.GetUserByIdAsync(num);

            if (userByIdAsync == null || userByIdAsync.PasswordResetCode.IsNullOrEmpty() || userByIdAsync.PasswordResetCode != model.ResetCode)
            {
                throw new UserFriendlyException(this.L("InvalidPasswordResetCode"), this.L("InvalidPasswordResetCode_Detail"));
            }
            TenantLogosEditDto tenantLogosEditDto = Abp.Threading.AsyncHelper.RunSync <TenantLogosEditDto>(() => this.GetCurrentTenantLogos());
            dynamic            viewBag            = this.ViewBag;

            guid = (tenantLogosEditDto.HeaderImageId.HasValue ? tenantLogosEditDto.HeaderImageId.Value : Guid.Empty);
            viewBag.TenantCompanyHeaderImageId = guid;
            dynamic obj = this.ViewBag;

            guid1 = (tenantLogosEditDto.HeaderMobileImageId.HasValue ? tenantLogosEditDto.HeaderMobileImageId.Value : Guid.Empty);
            obj.TenantCompanyHeaderMobileImageId = guid1;
            return(this.View(model));
        }
コード例 #5
0
        public virtual async Task <ActionResult> EmailConfirmation(EmailConfirmationViewModel model)
        {
            string tenancyName;

            this.CheckModelState();
            IActiveUnitOfWork current = this._unitOfWorkManager.Current;

            current.DisableFilter(new string[] { "MayHaveTenant" });
            long num = Convert.ToInt64(SimpleStringCipher.Decrypt(model.UserId, "gsKnGZ041HLL4IM8"));

            FuelWerx.Authorization.Users.User userByIdAsync = await this._userManager.GetUserByIdAsync(num);

            if (userByIdAsync == null || userByIdAsync.EmailConfirmationCode.IsNullOrEmpty() || userByIdAsync.EmailConfirmationCode != model.ConfirmationCode)
            {
                throw new UserFriendlyException(this.L("InvalidEmailConfirmationCode"), this.L("InvalidEmailConfirmationCode_Detail"));
            }
            userByIdAsync.IsEmailConfirmed      = true;
            userByIdAsync.EmailConfirmationCode = null;
            await this._userManager.UpdateAsync(userByIdAsync);

            if (!userByIdAsync.TenantId.HasValue)
            {
                tenancyName = "";
            }
            else
            {
                TenantManager tenantManager = this._tenantManager;
                int?          tenantId      = userByIdAsync.TenantId;
                tenancyName = (await tenantManager.GetByIdAsync(tenantId.Value)).TenancyName;
            }
            string       str    = tenancyName;
            ActionResult action = this.RedirectToAction("Login", new { successMessage = this.L("YourEmailIsConfirmedMessage"), tenancyName = str, userNameOrEmailAddress = userByIdAsync.UserName });

            return(action);
        }
コード例 #6
0
        public void Should_Be_Able_To_Change_InitVector_And_Key()
        {
            const string initVectorString = "1234BCHF9876skd*";
            const string myKey            = "84ncpaKMC_!TuAna";
            const string plainText        = "This is a plain text!";

            var cipher = new SimpleStringCipher
            {
                InitVectorBytes = Encoding.ASCII.GetBytes(initVectorString)
            };

            var enryptedText = cipher.Encrypt(plainText, myKey);

            cipher.Decrypt(enryptedText, myKey).ShouldBe(plainText);
        }
コード例 #7
0
        public virtual async Task <ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            CheckModelState();

            _unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant);

            var userId = Convert.ToInt64(SimpleStringCipher.Decrypt(model.UserId));

            var user = await _userManager.GetUserByIdAsync(userId);

            if (user == null || user.PasswordResetCode.IsNullOrEmpty() || user.PasswordResetCode != model.ResetCode)
            {
                throw new UserFriendlyException(L("InvalidPasswordResetCode"), L("InvalidPasswordResetCode_Detail"));
            }

            return(View(model));
        }
コード例 #8
0
        public void StoreFunctionInsertProperlyTheVaultRecordTest()
        {
            var vault     = new InMemoryVault();
            var cipher    = new SimpleStringCipher();
            var container = new VaultSecureContainer(vault, cipher);

            var title         = "Twitter";
            var password      = "******";
            var superPassword = "******";

            container.Store(title, password, superPassword);

            var record = vault.Get("Twitter");

            Assert.NotNull(record);
            Assert.Equal(title, record.Title);
            Assert.Equal(password, cipher.Decrypt(record.CipherPassword, superPassword));
            Assert.Equal(cipher.CalculateHash(superPassword), record.Sign);
        }
コード例 #9
0
        private void button_gamestart_Click(object sender, EventArgs e)
        {
            button_gamestart.Enabled = false;
            try
            {
                Process[] processesNt  = Process.GetProcessesByName("Nostale.dat");
                Process[] processesNtx = Process.GetProcessesByName("NostaleX.dat");
                Process[] processesOn  = Process.GetProcessesByName("NostaleOpen.dat");
                if (processesNt.Length > 0 || processesOn.Length > 0 || processesNtx.Length > 0)
                {
                    // There is already an instance running
                    MessageBox.Show(_l.T("ONLYONEINSTANCE"), _l.T("ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    try
                    {
                        IPAddress[] hostAddresses = Dns.GetHostAddresses(textBox_server.Text);
                        IPAddress   ipAddress     = hostAddresses.Contains(IPAddress.Parse("127.0.0.1"))
                            ? IPAddress.Parse("127.0.0.1")
                            : hostAddresses[0];

                        int port = 4000 + _l.Lng.GetHashCode();

                        if (!string.IsNullOrEmpty(_cfg["Form"]["OverridePort"]))
                        {
                            int.TryParse(_cfg["Form"]["OverridePort"], out port);
                        }
                        else
                        {
                            _cfg["Form"]["OverridePort"] = "";
                        }

                        string result = NosModder.GoWithIniFile(_cfg["Graph"]["Mode"] != "GL", ipAddress.ToString(), port);

                        if (result != "ok")
                        {
                            MessageBox.Show(_l.T(result), _l.T("Fehler"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            Hide();

                            int tmp;
                            int.TryParse(_cfg["Autologin"]["Delay"], out tmp);
                            if (tmp < 750)
                            {
                                tmp = 1250;
                            }
                            else if (tmp > 10000)
                            {
                                tmp = 10000;
                            }
                            _cfg["Autologin"]["Delay"] = tmp.ToString();

                            string password = "";
                            try
                            {
                                password = SimpleStringCipher.Decrypt(_cfg["Autologin"]["Password"], "OPENNOSROCKXXX");
                            }
                            catch (Exception exception)
                            {
                                MessageBox.Show(exception.ToString(), _l.T("ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                                Application.Exit();
                            }

                            Thread.Sleep(3000);

                            if (_cfg["Autologin"]["Enabled"] != "0")
                            {
                                NosModder.SendCredentials(textBox_username.Text, password, _cfg);
                            }

                            Application.Exit();
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.ToString(), _l.T("ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), _l.T("Fehler"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            button_gamestart.Enabled = true;
        }