Пример #1
0
        public virtual async Task <IActionResult> SetPasswordAsync([FromBody][Required] SetPassword <TIdentity> setPassword, CancellationToken cancellationToken = default)
        {
            await this.IdentityManager
            .SetPasswordAsync(setPassword, cancellationToken);

            return(this.Ok());
        }
        public void SetPasswordTest()
        {
            // TODO: add unit test for the method 'SetPassword'
            SetPassword model = null; // TODO: replace null with proper value

            instance.SetPassword(model);
        }
Пример #3
0
        public async Task <IActionResult> SetPassword(SetPassword model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }

            var addPasswordResult = await _userManager.AddPasswordAsync(user, model.NewPassword);

            if (!addPasswordResult.Succeeded)
            {
                foreach (var error in addPasswordResult.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
                return(View(model));
            }

            await _signInManager.RefreshSignInAsync(user);

            StatusMessage = "Parola ta a fost setată.";

            return(RedirectToAction());
        }
        public ReturnStatus SetPassword(SetPassword req)
        {
            using (var connection = new SqlConnection(_connectionString.HotelManagement))
            {
                var cmd = new SqlCommand(p_ChangePassword_Set, connection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                cmd.Parameters.AddWithValue("@UserID", _requestInfo.UserId);

                cmd.Parameters.Add("@RetVal", SqlDbType.Int).Direction          = ParameterDirection.Output;
                cmd.Parameters.Add("@RetMsg", SqlDbType.VarChar, 500).Direction = ParameterDirection.Output;

                cmd.Parameters.AddWithValue("@UserName", req.UserName);

                cmd.Parameters.AddWithValue("@CurrentPassword", req.CurrentPassword);
                cmd.Parameters.AddWithValue("@NewPassword", req.NewPassword);

                connection.Open();

                cmd.ExecuteNonQuery();

                return(new ReturnStatus(cmd.Parameters["@RetVal"].Value.ToSafeInt32(), cmd.Parameters["@RetMsg"].Value.ToSafeString()));
            }
        }
        private async void SetPasswordButton_Click(object sender, RoutedEventArgs e)
        {
            ResetDisplay();
            SetPassword setPassword = new SetPassword()
            {
                NewPassword     = NewPasswordBox.Password,
                ConfirmPassword = ConfirmPasswordBox.Password
            };

            HttpResult result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.SetPasswordAsync(setPassword);
            }

            if (result.Succeeded)
            {
                AppSettings settings = new AppSettings();
                settings.SavePasswordCredential(this.username, setPassword.NewPassword);
                AccountsSettingsPane.Show();
            }
            else
            {
                DisplayErrors(result.Errors);
            }
            ClearPasswords();
        }
Пример #6
0
        private async void SetPasswordButton_Click(object sender, RoutedEventArgs e)
        {
            ClearErrors();
            SetPassword setPassword = new SetPassword()
            {
                NewPassword     = NewPasswordBox.Password,
                ConfirmPassword = ConfirmPasswordBox.Password
            };

            HttpResult result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.SetPasswordAsync(setPassword);
            }

            if (result.Succeeded)
            {
                this.NavigationService.Navigate(new Uri("/SettingsPage.xaml", UriKind.Relative));
            }
            else
            {
                DisplayErrors(result.Errors);
            }
            ClearPasswords();
        }
Пример #7
0
    public static string ShowForm()
    {
        returnval = null;
        SetPassword SP = new SetPassword();

        SP.ShowDialog();
        return(returnval);
    }
Пример #8
0
 public Task <Models.User> CheckPasswordAsync(string tokenKey, SetPassword password)
 {
     return(Task.Factory.StartNew(() =>
     {
         var res = RestClient.Post <Models.User>(HttpWebRequest.Create(string.Format(EndPointsList.CheckPasswordUrl, tokenKey)), string.Empty, password.ToJson());
         return res;
     }));
 }
Пример #9
0
 public Task <int> VerifyPasswordAsync(string qrCode, SetPassword password)
 {
     return(Task.Factory.StartNew(() =>
     {
         var res = RestClient.Post <int>(HttpWebRequest.Create(string.Format(EndPointsList.VerifyPasswordUrl, qrCode)), string.Empty, password.ToJson());
         return res;
     }));
 }
Пример #10
0
 public bool SetPassword(SetPassword Passwordmodel)
 {
     try {
         bool result = userRepository.SetPassword(Passwordmodel);
         return(true);
     }
     catch (Exception e) { }
     return(false);
 }
Пример #11
0
        private void btnPassword_Click(object sender, EventArgs e)
        {
            // パスワード変更
            SetPassword setPassword = new SetPassword
            {
                Text = btnPassword.Text
            };

            setPassword.ShowDialog();
        }
Пример #12
0
        /// <summary>
        /// Createa a password for a user.
        /// Used when logged in using external login provider, and no password has been created for the user.
        /// </summary>
        /// <param name="setPassword">The <see cref="SetPassword"/>.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
        /// <returns>Void.</returns>
        public virtual async Task SetPasswordAsync(SetPassword setPassword, CancellationToken cancellationToken = default)
        {
            if (setPassword == null)
            {
                throw new ArgumentNullException(nameof(setPassword));
            }

            var user = await this.UserManager
                       .FindByIdAsync(setPassword.UserId);

            await this.UserManager
            .AddPasswordAsync(user, setPassword.NewPassword);
        }
Пример #13
0
        public SetPasswordResponse Post(SetPassword request)
        {
            var user = Db.SingleById <PortalTempUser>(request.Id);

            user.UserName = request.Username;
            var count       = Db.Update(user, u => u.Id == request.Id);
            var authSession = user.ConvertTo <UserAuth>();

            authRepository.CreateUserAuth(authSession, request.Password);
            return(new SetPasswordResponse {
                IsDone = count > 0
            });
        }
Пример #14
0
 // Use this for initialization
 void Start()
 {
     images     = new Sprite[5];
     images [0] = s0;
     images [1] = s1;
     images [2] = s2;
     images [3] = s3;
     images [4] = pass;
     pword      = false;
     changeImage();
     setpassword = GameObject.FindGameObjectWithTag("PWRD").GetComponent <SetPassword>();
     Image[] pw1 = setpassword.pw1;
     Image[] pw2 = setpassword.pw2;
 }
Пример #15
0
        public async Task <IHttpActionResult> SetPassword(SetPassword newPassword)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (Rbac.ChangePassword(User.Identity.GetUserName(), newPassword.OldPassword, newPassword.NewPassword))
            {
                return(Ok());
            }

            return(BadRequest("User is not defined!"));
        }
Пример #16
0
        public ChangePasswordViewModel()
        {
            _dialogs = new DialogObjects();
            _dialogs.SetViewModel(this);

            _service = new ChangePasswordsService();

            SaveCmd = new DelegateCommand(OnSave);

            SaveReq = new SetPassword();

            CurrentPassword = string.Empty;
            NewPassword     = string.Empty;
            ConfirmPassword = string.Empty;
        }
Пример #17
0
        public async Task <IResult <UserInfoDetails> > SetPasswordAsync(long userId, string password)
        {
            var request = new Request("Security/Users/{id}/Action/Password/Set", Method.PUT);

            request.AddUrlSegment("id", userId.ToString());

            // Not documented by Orion
            var body = new SetPassword {
                NewPassword = password,
                ResetUser   = false
            };

            request.AddParameter("application/json", JsonConvert.SerializeObject(body));
            return(await client.ExecuteTaskAsync <UserInfoDetails>(request));
        }
        public void should_call_SetPassword()
        {
            //arrange
            var userId  = AddContact();
            var request = new SetPassword
            {
                Password = "******",
            };
            //act
            var actual = Sut.SetPassword(userId, request);

            //assert
            Assert.AreEqual(200, actual.Code);
            Assert.IsEmpty(actual.Message);
            Assert.AreEqual("OK", actual.Status);
        }
Пример #19
0
        private void Next(object sender, RoutedEventArgs e)
        {
            var username = Username.Text;
            if (String.IsNullOrWhiteSpace(username)) return;

            if (_users.Exists(username))
            {
                ExistingUser(username, _users);
            }
            else
            {
                var nextPage = new SetPassword(username, _users);
                nextPage.Return += AddUser;
                NavigationService.Navigate(nextPage);
            }
        }
Пример #20
0
        public ActionResult RetrievePasswordSuccess(SetPassword model)
        {
            ViewBag.HasError = false;
            if (ModelState.IsValid)
            {
                if (UnitOfWork <UserManager>().ChangePassword(model.UserName, model.OldPassword, model.NewPassword))
                {
                    return(View("ChangePasswordSuccess"));
                }
                ViewBag.HasError = true;
                ModelState.AddModelError("", ControllerResources.AccountController_ChangePassword_The_current_password_is_incorrect_or_the_new_password_is_invalid_);
            }

            // If we got this far, something failed, redisplay form
            ViewBag.PasswordLength = UnitOfWork <UserManager>().MinPasswordLength;
            return(View(model));
        }
        public static void Main(string[] args)
        {
            //// ***********************************************************
            ////          GroupDocs.Comparison Cloud API Examples
            //// ***********************************************************

            //TODO: Get your Client Id and Client secret at https://dashboard.groupdocs.cloud (free registration is required).
            Constants.MyClientId     = "XXXX-XXXX-XXXX-XXXX";
            Constants.MyClientSecret = "XXXXXXXXXXXXXXXX";
            Constants.MyStorage      = "First Storage";


            // Uploading sample test files from local disk to cloud storage
            Constants.UploadSampleTestFiles();

            #region Basic usage
            GetSupportedFormats.Run();
            GetDocumentInformation.Run();
            CompareDocuments.Run();
            ComparePdfDocuments.Run();
            #endregion

            #region Advanced usage
            CompareProtectedDocuments.Run();
            AcceptOrRejectChanges.Run();
            CompareMultipleDocumentsOptions.Run();
            CompareMultipleProtectedDocuments.Run();
            CompareSensitivity.Run();
            CustomizeChangesStyles.Run();
            GetListOfChanges.Run();
            GetChangesCoordinates.Run();
            SetPassword.Run();
            SetMetadata.Run();

            GetListOfRevisions.Run();
            ApplyRevisions.Run();
            AcceptAllRevisions.Run();
            RejectAllRevisions.Run();
            #endregion


            Console.WriteLine("Completed!");
            Console.ReadKey();
        }
Пример #22
0
        public void SetPassword(SetPassword setPassword)
        {
            using (var db = new RAAPMasterEntities())
            {
                var dataUser = db.Users.FirstOrDefault(u => u.UserId == setPassword.UserId);
                if (dataUser == null)
                {
                    throw new RAAPNotFoundException("Item not found.");
                }

                if (string.IsNullOrEmpty(setPassword.Password) || setPassword.Password.Length < 4)
                {
                    throw new RAAPConflictException("Password must at least be 4 characters.");
                }

                dataUser.PasswordHash = Common.Security.Password.ComputeHash(setPassword.Password, dataUser.CreatedOn.Date.Ticks.ToString());
                db.SaveChanges();
            }
        }
Пример #23
0
        public bool SetPassword(SetPassword changePassword)
        {
            SqlCommand cmd = new SqlCommand("ChangePassword", sqlConnection);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@email", changePassword.Email);
            cmd.Parameters.AddWithValue("@newpassword", changePassword.NewPassword);
            sqlConnection.Open();
            int i = (int)cmd.ExecuteScalar();

            sqlConnection.Close();
            if (i == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// Create a user to AD.
        /// </summary>
        /// <param name="ldapConnectionInfo">The LDAP connection information</param>
        /// <param name="adUser">The user record to be created</param>
        /// <param name="Password">Passes two parameters to this task: bool setPassword, which defines if a password should be set at create time, and string newPassword, containing the password to be set.</param>
        /// <returns>LdapResult class, which carries a copy of the created user record.</returns>
        public static OutputUser AD_CreateUser([PropertyTab] LdapConnectionInfo ldapConnectionInfo, [PropertyTab] CreateADuser adUser, AD_CreateUserProperties Password)
        {
            var ldapOperationResult = new OutputUser {
                operationSuccessful = false, user = null
            };

            using (var ldap = new LdapService(ldapConnectionInfo))
            {
                ldapOperationResult.user = ldap.CreateAdUser(adUser);

                if (Password.setPassword)
                {
                    SetPassword.SetUserPassword(ldapConnectionInfo.LdapUri, adUser.Path, ldapConnectionInfo.Username, ldapConnectionInfo.Password, adUser.CN, Password.newPassword);
                }

                ldapOperationResult.operationSuccessful = true;

                return(ldapOperationResult);
            }
        }
Пример #25
0
        public async Task <IActionResult> SetPassword()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }

            var hasPassword = await _userManager.HasPasswordAsync(user);

            if (hasPassword)
            {
                return(RedirectToAction("ChangePassword"));
            }

            var model = new SetPassword();

            model.StatusMessage = StatusMessage;
            return(View(model));
        }
Пример #26
0
        public async Task <IActionResult> SetPassword(SetPassword model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = await GetCurrentUserAsync();

            if (user != null)
            {
                var result = await _userManager.AddPasswordAsync(user, model.NewPassword);

                if (result.Succeeded)
                {
                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(RedirectToAction(nameof(Index), new { Message = ManageMessageId.SetPasswordSuccess }));
                }
                AddErrors(result);
                return(View(model));
            }
            return(RedirectToAction(nameof(Index), new { Message = ManageMessageId.Error }));
        }
        public async Task <IHttpActionResult> SetPassword(SetPassword model)
        {
            if (model == null)
            {
                ModelState.AddModelError("", "Data required");
            }

            if (ModelState.IsValid)
            {
                var result = await this.userManager.SetPasswordAsync(model.Subject, model.Password);

                if (result.IsSuccess)
                {
                    return(Ok(UserManagerResult.Success));
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error);
                }
            }

            return(BadRequest(ModelState.GetErrorMessage()));
        }
Пример #28
0
        public async Task <IActionResult> Put([FromBody] SetPassword command)
        {
            await CommandDispatcher.DispatchAsync(command);

            return(NoContent());
        }
Пример #29
0
        private void SetupViews()
        {
            Messenger.Default.Register <string>(this, "OpenAboutView", (string s) => About.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseAboutView", (string s) => About.Close());

            Messenger.Default.Register <string>(this, "OpenCreateWalletView", (string s) => CreateWallet.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseCreateWalletView", (string s) => CreateWallet.Close());

            Messenger.Default.Register <string>(this, "OpenLicenseView", (string s) => License.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseLicenseView", (string s) => License.Close());

            Messenger.Default.Register <string>(this, "OpenManageWalletView", (string s) => ManageWallet.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseManageWalletView", (string s) => ManageWallet.Close());

            Messenger.Default.Register <string>(this, "OpenPromptPasswordView", (string s) => PromptPassword.ShowDialog());
            Messenger.Default.Register <string>(this, "ClosePromptPasswordView", (string s) => PromptPassword.Close());

            Messenger.Default.Register <string>(this, "OpenReceiveView", (string s) => Receive.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseReceiveView", (string s) => Receive.Close());

            Messenger.Default.Register <string>(this, "OpenRecoverWalletView", (string s) => RecoverWallet.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseRecoverWalletView", (string s) => RecoverWallet.Close());

            Messenger.Default.Register <string>(this, "OpenRecoveryPhraseView", (string s) => RecoveryPhrase.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseRecoveryPhraseView", (string s) => RecoveryPhrase.Close());

            Messenger.Default.Register <string>(this, "OpenSendView", (string s) => Send.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseSendView", (string s) => Send.Close());

            Messenger.Default.Register <string>(this, "OpenSetLanguageView", (string s) => SetLanguage.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseSetLanguageView", (string s) => SetLanguage.Close());

            Messenger.Default.Register <string>(this, "OpenSetPasswordView", (string s) => SetPassword.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseSetPasswordView", (string s) => SetPassword.Close());

            Messenger.Default.Register <string>(this, "OpenSimpleDialogView", (string s) => SimpleDialog.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseSimpleDialogView", (string s) => SimpleDialog.Close());

            Messenger.Default.Register <string>(this, "OpenTxInfoView", (string s) => TxInfo.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseTxInfoView", (string s) => TxInfo.Close());

            Messenger.Default.Register <string>(this, "OpenWalletInfoView", (string s) => WalletInfo.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseWalletInfoView", (string s) => WalletInfo.Close());

            Messenger.Default.Register <string>(this, "OpenWelcomeView", (string s) => Welcome.ShowDialog());
            Messenger.Default.Register <string>(this, "CloseWelcomeView", (string s) => Welcome.Close());
        }
        public async Task<IHttpActionResult> SetPassword(SetPassword model)
        {
            if (model == null)
            {
                ModelState.AddModelError("", "Data required");
            }

            if (ModelState.IsValid)
            {
                var result = await this.userManager.SetPasswordAsync(model.Subject, model.Password);
                if (result.IsSuccess)
                {
                    return Ok(UserManagerResult.Success);
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error);
                }
            }

            return BadRequest(ModelState.GetErrorMessage());
        }
Пример #31
0
        private void btnSetPassword_Click(object sender, EventArgs e)
        {
            SetPassword sp = new SetPassword();

            sp.Show();
        }
 /// <summary>
 /// Set a password
 /// details: https://developer.chargeover.com/apidocs/rest/#set-a-password
 /// </summary>
 public ICustomResponse <bool> SetPassword(int userId, SetPassword request)
 {
     return(GetCustomBool($"/user/{userId}?action=password", request));
 }
Пример #33
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.set_password);

            SetTitle(Resource.String.password_title);

            // Ok button
            Button okButton = (Button) FindViewById(Resource.Id.ok);
            okButton.Click += (sender, e) =>
            {
                TextView passView = (TextView) FindViewById(Resource.Id.pass_password);
                String pass = passView.Text;
                TextView passConfView = (TextView) FindViewById(Resource.Id.pass_conf_password);
                String confpass = passConfView.Text;

                // Verify that passwords match
                if ( ! pass.Equals(confpass) ) {
                    // Passwords do not match
                    Toast.MakeText(Context, Resource.String.error_pass_match, ToastLength.Long).Show();
                    return;
                }

                TextView keyfileView = (TextView) FindViewById(Resource.Id.pass_keyfile);
                String keyfile = keyfileView.Text;
                Keyfile = keyfile;

                // Verify that a password or keyfile is set
                if ( pass.Length == 0 && keyfile.Length == 0 ) {
                    Toast.MakeText(Context, Resource.String.error_nopass, ToastLength.Long).Show();
                    return;

                }

                SetPassword sp = new SetPassword(Context, App.Kp2a, pass, keyfile, new AfterSave(this, _finish, new Handler()));
                ProgressTask pt = new ProgressTask(App.Kp2a, Context, sp);
                pt.Run();
            };

            // Cancel button
            Button cancelButton = (Button) FindViewById(Resource.Id.cancel);
            cancelButton.Click += (sender,e) => {
                Cancel();
                if ( _finish != null ) {
                    _finish.Run();
                }
            };
        }