frontend/controllers/UserController.php
/**
     * Renders change Password Page
     *
     * @return mixed
     */
Renders change Password Page
@return mixed
Renders change Password Page @return mixed
public function actionChangePassword ()
    {
        $this->layout = 'site';
        $url_lang = explode('-', Yii::$app->language);
        $lang_path = $url_lang[0];
        if(!Yii::$app->user->isGuest){
            $model = new ChangeModel;
            $modeluser = \common\models\User::find()->where([
                'email'=>Yii::$app->user->identity->email
                ])->one();
            $isReseller = $modeluser->hasRole('reseller');
            if ($isReseller) {
                $this->layout = 'reseller';
            }
            if($model->load(Yii::$app->request->post())){
                if($model->validate()){
                    try{
                        $modeluser->password = $_POST['ChangeModel']['newpass'];
                            if($modeluser->save()){
                                \Yii::$app->session->setFlash('consol_v_error',\Yii::t('app/consol', 'Password successfully updated'));
                                if ($isReseller) {
                                    return $this->redirect('@reseller_profile');
                                }
                                return $this->redirect('/profile');
                            }
                        }
                    catch(Exception $e){
                        return $this->render('change-password',[
                            'model'=>$model,
                            'lang'=>$lang_path,
                        ]);
                    }
                }
                else{
                    $model->oldpass       = null;
                    $model->newpass       = null;
                    $model->repeatnewpass = null;
                    return $this->render('change-password',[
                        'model'=>$model,
                        'lang'=>$lang_path,
                        ]);
                    }
            }
            else{
                return $this->render('change-password',[
                    'model'=>$model,
                    'lang'=>$lang_path,
                ]);
            }
        }
    }
public function actionChangePassword ( ) { $ this -> layout = 'site' ; $ url_lang = explode ( '-' , Yii :: $ app -> language ) ; $ lang_path = $ url_lang [ 0 ] ; if ( ! Yii :: $ app -> user -> isGuest ) { $ model = new ChangeModel ; $ modeluser = \ common \ models \ User :: find ( ) -> where ( [ 'email' => Yii :: $ app -> user -> identity -> email ] ) -> one ( ) ; $ isReseller = $ modeluser -> hasRole ( 'reseller' ) ; if ( $ isReseller ) { $ this -> layout = 'reseller' ; } if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( $ model -> validate ( ) ) { try { $ modeluser -> password = $ _POST [ 'ChangeModel' ] [ 'newpass' ] ; if ( $ modeluser -> save ( ) ) { \ Yii :: $ app -> session -> setFlash ( 'consol_v_error' , \ Yii :: t ( 'app/consol' , 'Password successfully updated' ) ) ; if ( $ isReseller ) { return $ this -> redirect ( '@reseller_profile' ) ; } return $ this -> redirect ( '/profile' ) ; } } catch ( Exception $ e ) { return $ this -> render ( 'change-password' , [ 'model' => $ model , 'lang' => $ lang_path , ] ) ; } } else { $ model -> oldpass = null ; $ model -> newpass = null ; $ model -> repeatnewpass = null ; return $ this -> render ( 'change-password' , [ 'model' => $ model , 'lang' => $ lang_path , ] ) ; } } else { return $ this -> render ( 'change-password' , [ 'model' => $ model , 'lang' => $ lang_path , ] ) ; } } }
Renders change Password Page
 @return mixed
Renders change Password Page @return mixed