Blame view

frontend/controllers/LoginController.php 1.33 KB
ecf49b1b   Administrator   second
1
2
3
4
5
6
  <?php
  
  namespace frontend\controllers;
  
  use Yii;
  use yii\web\Controller;
7ba4acc5   Administrator   after marge
7
8
  use frontend\models\LoginForm;
  use common\models\Customer;
ecf49b1b   Administrator   second
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  
  class LoginController extends Controller
  {
  	//public $layout='layout';
      public function actionIndex()
      {
          if (!\Yii::$app->user->isGuest) {
              return $this->goHome();
          }
  
          $model = new LoginForm();
          if ($model->load(Yii::$app->request->post()) && $model->login()) {
              return $this->goBack();
          } else {
              return $this->render('index', [
                  'model' => $model,
              ]);
          }
      }
  	
      public function actionLogout()
      {
          Yii::$app->user->logout();
  
          return $this->goHome();
      }
      
      public function actionForgot(){
bb50c493   Dmytry Fedorchuk   images
37
  //var_dump($_POST['Customer']['username']);die();
7ba4acc5   Administrator   after marge
38
              $model = new Customer;
ffe503d1   Dmytry Fedorchuk   images
39
              if(!empty($_POST['Customer']['username'])){
7ba4acc5   Administrator   after marge
40
                  if($user = Customer::find()->where(['username'=>$_POST['User']['username']])->one())
ecf49b1b   Administrator   second
41
42
43
44
                      $user->sendMsg();
                  Yii::$app->getSession()->setFlash('success', 'На указанный Вами эмейл отправленно письмо с паролем!');
                  return $this->refresh();
              }
7ba4acc5   Administrator   after marge
45
  
ecf49b1b   Administrator   second
46
47
              return $this->render('forgot', [
                  'model' => $model,
7ba4acc5   Administrator   after marge
48
              ]);
ecf49b1b   Administrator   second
49
50
      }
  }