function actionMentorAuth() { $mentor = Mentor::findOne(['login' => $this->get["login"], "password" => md5($this->get["password"])]); if (!$mentor) { $r = $this->setError(201); } elseif ($mentor->token != "") { $r = $this->setError(202); } else { $station = Stations::findOne(['hash' => $this->get["hash"]]); if (count($station) == 0) { $r = $this->setError(101); } else { $r["status"] = "ok"; $token = md5($mentor->login . time()); $mentor->token = $token; $mentor->save(); $sess_station = new SessStation(); $sess_station->id_station = $station->id; $sess_station->id_mentor = $mentor->id; $sess_station->input = time(); $sess_station->token = $token; $sess_station->save(); $r["token"] = $token; } } return json_encode($r); }
public function getSessStation() { return $this->hasOne(SessStation::className(), ['id_station' => 'id'])->where(['exit' => 0]); }