コード例 #1
0
ファイル: SiteController.php プロジェクト: Sywooch/babydiary
 public function actionLogin()
 {
     $model = new Login();
     $params = json_decode(trim(file_get_contents('php://input')), true);
     $model->email = $params['email'];
     $model->password = $params['password'];
     $model->rememberMe = isset($params['remember']) ? $params['remember'] : false;
     if ($model->login()) {
         return '{success : true}';
     } else {
         return $this->render('widgetLogin', ['model' => $model]);
     }
 }
コード例 #2
0
 public function actionLogin()
 {
     $model = new Login();
     //print_r(Yii::$app->request->post());
     //exit;
     $data = $model->load(Yii::$app->request->post());
     $msg = "";
     //print_r($model);
     if ($model->login()) {
         // Get the actual logged user
         //echo "login";
         //print_r( Yii::$app->user->getIdentity() );
         //exit;
         //Yii::$app->user->getIdentity()
         //return $this->goBack();
         //return $this->actionIndex();
         $this->redirect(array('server/index'));
     } else {
         $msg = "Please verify  user and password.";
     }
     $this->layout = 'login';
     return $this->render('login', array('model' => $model, 'msg' => $msg));
 }
コード例 #3
0
 public function social(ClientInterface $client)
 {
     $user_data = new UserData($client->getName(), $client->getUserAttributes());
     if (Yii::$app->user->isGuest) {
         $user = User::findSocial($user_data->getObjectName(), $user_data->getObjectName());
         if ($user) {
             Login::login($user);
         } else {
             $user_data->save();
         }
     } else {
         User::saveSocial(Yii::$app->user->identity, $user_data);
     }
     Yii::$app->session->set('social', $client->getName());
 }