public static function setNewRecipientInfo($model, $info_type, $params) { try { $user_info = new RecipientMobileInfo(); $user_info->recipient_mobile_index = $model->index; $user_info->info_type = $info_type; $user_info->occured_at = Utils::getCurrentTime(); if (ApiParams::checkLocationParams($params)) { $user_info->pos_lat = $params[ApiParams::POS_LNG]; $user_info->pos_lng = $params[ApiParams::POS_LAT]; } elseif (ApiParams::checkIfThereAreNote($params)) { $user_info->note = $params[ApiParams::NOTE]; } return $user_info->save(); } catch (\Exception $e) { return $e; } }
public function actionUserRestorePassword() { $params = ApiParams::getPostJsonParams(); $model = Validation::AuthorizedUserToResetThePassword($params); if ($model->errors) { Utils::echoErrorResponse($model->getFirstErrors()); } else { if (!$model->security_question) { Utils::echoErrorResponse(["error" => "You did not register security question, call support"]); } else { $good_answer = $model->checkAnswer($params[ApiParams::SECURITY_QUESTION], $params[ApiParams::SECURITY_QUESTION_ANSWER]); if (!$good_answer) { Utils::echoErrorResponse(["error" => "Wrong security question or answer"]); } else { RecipientMobileInfo::setNewRecipientInfo($model, InfoTypes::RESTORE_PASSWORD, $params); Utils::echoSuccessResponse("New Password set"); } } } }