Fixing API calls
This commit is contained in:
@@ -66,12 +66,11 @@ class AuthController extends Controller
|
||||
$user = User::findOne(['email' => $data['email'] ?? null]);
|
||||
if (!$user || !Yii::$app->security->validatePassword($data['password'], $user->password_hash)) {
|
||||
throw new UnauthorizedHttpException();
|
||||
return ['error' => 'Invalid credentials'];
|
||||
}
|
||||
// @todo not sure if it makes sense to generate an auth key each login via the API?
|
||||
$user->generateAuthKey();
|
||||
$user->save();
|
||||
|
||||
return ['token' => $this->generateJwt($user)];
|
||||
}e
|
||||
}
|
||||
}
|
||||
@@ -29,9 +29,10 @@ class MealController extends ActiveController
|
||||
{
|
||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
$model = new MealForm();
|
||||
$model->load(Yii::$app->request->post());
|
||||
$model->picture = UploadedFile::getInstance($model, 'picture');
|
||||
if ($model->upload()) {
|
||||
$id = \Yii::$app->gemini->mealInquiry(Yii::getAlias('@frontend/web/'.$model->filepath));
|
||||
$id = \Yii::$app->gemini->mealInquiry($model);
|
||||
return array_merge(['meal' => Meal::findOne($id)], $this->actionGetDailySummary());
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ class GeminiApiComponent extends \yii\base\Component
|
||||
"parts" => [
|
||||
[
|
||||
"inline_data" => [
|
||||
"data" => base64_encode(file_get_contents($model->filepath)),
|
||||
"mimeType" => FileHelper::getMimeType($model->filepath)
|
||||
"data" => base64_encode(file_get_contents(Yii::getAlias('@frontend/web/') . $model->filepath)),
|
||||
"mimeType" => FileHelper::getMimeType(Yii::getAlias('@frontend/web/') . $model->filepath)
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user