src/commands/SetupController.php
public function actionResetPassword()
    {
        /** @var User $user */
        $user = null;
        
        while (empty($user)) {
            $email = $this->email ?: $this->prompt('User E-Mail:');
            $user = User::findByEmail($email);
            if (empty($user)) {
                $this->outputError('The provided E-Mail not found in the System.');
            }
        }
    
        $password = $this->password ?: $this->prompt('User Password:');
    
        if ($this->confirm("Are you sure to change the password of User '$email'?") !== true) {
            return $this->outputError('Abort password change process.');
        }
        
        $user->password_salt = Yii::$app->getSecurity()->generateRandomString();
        $user->password = Yii::$app->getSecurity()->generatePasswordHash($password.$user->password_salt);
        if ($user->save(true, ['password', 'password_salt'])) {
            return $this->outputSuccess("The password for user ($email) has been changed.");
        }
    
        return $this->outputError("The password could not changed.\n" . implode("\n", $user->firstErrors));
    }
public function actionResetPassword()
    {
        /** @var User $user */
        $user = null;
        
        while (empty($user)) {
            $email = $this->email ?: $this->prompt('User E-Mail:');
            $user = User::findByEmail($email);
            if (empty($user)) {
                $this->outputError('The provided E-Mail not found in the System.');
            }
        }
    
        $password = $this->password ?: $this->prompt('User Password:');
    
        if ($this->confirm("Are you sure to change the password of User '$email'?") !== true) {
            return $this->outputError('Abort password change process.');
        }
        
        $user->password_salt = Yii::$app->getSecurity()->generateRandomString();
        $user->password = Yii::$app->getSecurity()->generatePasswordHash($password.$user->password_salt);
        if ($user->save(true, ['password', 'password_salt'])) {
            return $this->outputSuccess("The password for user ($email) has been changed.");
        }
    
        return $this->outputError("The password could not changed.\n" . implode("\n", $user->firstErrors));
    }
public function actionResetPassword ( ) { /** @var User $user */ $ user = null ; while ( empty ( $ user ) ) { $ email = $ this -> email ? : $ this -> prompt ( 'User E-Mail:' ) ; $ user = User :: findByEmail ( $ email ) ; if ( empty ( $ user ) ) { $ this -> outputError ( 'The provided E-Mail not found in the System.' ) ; } } $ password = $ this -> password ? : $ this -> prompt ( 'User Password:' ) ; if ( $ this -> confirm ( "Are you sure to change the password of User '$email'?" ) !== true ) { return $ this -> outputError ( 'Abort password change process.' ) ; } $ user -> password_salt = Yii :: $ app -> getSecurity ( ) -> generateRandomString ( ) ; $ user -> password = Yii :: $ app -> getSecurity ( ) -> generatePasswordHash ( $ password . $ user -> password_salt ) ; if ( $ user -> save ( true , [ 'password' , 'password_salt' ] ) ) { return $ this -> outputSuccess ( "The password for user ($email) has been changed." ) ; } return $ this -> outputError ( "The password could not changed.\n" . implode ( "\n" , $ user -> firstErrors ) ) ; }
Change the password of a admin user.

@return bool
@since 2.0.0
Change the password of a admin user .