コード例 #1
0
 public function actionLogin()
 {
     $post = Application::request()->post();
     $warning = '';
     if (!empty($post['email'])) {
         $model = new User();
         $user = $model->findByField('email', $post['email']);
         if ($user) {
             if (Helper::compareHash($user['password'], $post['password'])) {
                 Application::Identity()->checkin($user['user_id']);
                 $this->redirect('/search');
             } else {
                 $warning = 'Password is wrong';
             }
         } else {
             $warning = 'E-mail not found';
         }
     }
     if (!Application::Identity()->check()) {
         $this->render('login.html', ['warning' => $warning]);
     } else {
         $this->redirect('/search');
     }
 }