From 41956a396e996d141529ebc87e885af85547912b Mon Sep 17 00:00:00 2001
From: "HESU\\HESU" <1696136552@qq.com>
Date: Sat, 22 Mar 2025 14:03:58 +0800
Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/php.xml | 34 -----------
.idea/workspace.xml | 65 --------------------
app/controller/UserController.php | 77 +++++++++++++++++++++++-
resource/translations/en/messages.php | 1 +
resource/translations/zh_CN/messages.php | 1 +
5 files changed, 78 insertions(+), 100 deletions(-)
delete mode 100644 .idea/php.xml
delete mode 100644 .idea/workspace.xml
diff --git a/.idea/php.xml b/.idea/php.xml
deleted file mode 100644
index d29ced6..0000000
--- a/.idea/php.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index b76164b..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- $PROJECT_DIR$/webman/composer.json
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1741661680676
-
-
- 1741661680676
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/controller/UserController.php b/app/controller/UserController.php
index d445dbf..c753241 100644
--- a/app/controller/UserController.php
+++ b/app/controller/UserController.php
@@ -167,6 +167,81 @@ class UserController
}
}
+ /**
+ * 修改
+ * @param Request $request
+ * @return \support\Response
+ * @throws \Random\RandomException
+ */
+ public function save(Request $request)
+ {
+ $name = Util::getParam($request, 'name');
+ $sex = Util::getParam($request, 'sex');
+ $position = Util::getParam($request, 'position');
+ $country_id = Util::getParam($request, 'country_id');
+ $sign = Util::getParam($request, 'sign');
+ $id = $request->user['id'];
+
+ $data = [
+ 'name' => $name,
+ 'sex' => $sex,
+ 'position' => $position,
+ 'country_id' => $country_id,
+ 'sign' => $sign,
+ ];
+
+ $res = User::where('id', $id)
+ ->update($data);
+
+ if ($res) {
+ return Util::success($res, trans('save_success'));
+ } else {
+ return Util::fail($res, trans('save_fail'));
+ }
+ }
+
+ /**
+ * 修改
+ * @param Request $request
+ * @return \support\Response
+ * @throws \Random\RandomException
+ */
+ public function savePassword(Request $request)
+ {
+ $password = Util::getParam($request, 'password');
+ $email = Util::getParam($request, 'email');
+ $code = Util::getParam($request, 'code');
+ $verification_code = Redis::get("verification_code:{$email}");
+ $id = $request->user['id'];
+
+ if ($code != $verification_code) {
+ return Util::fail([], trans('code_error'));
+ }
+
+ $res = User::where('id', $id)
+ ->first();
+ if($res['email'] != $email) {
+ return Util::fail([], trans('email_consistent'));
+ }
+
+ //加密
+// $hashedPassword = password_hash($password, PASSWORD_DEFAULT);
+ $hashedPassword = password_hash($password, PASSWORD_DEFAULT);
+
+ $data = [
+ 'password' => $hashedPassword
+ ];
+
+ $res = User::where('id', $id)
+ ->update($data);
+
+ if ($res) {
+ return Util::success($res, trans('save_success'));
+ } else {
+ return Util::fail($res, trans('save_fail'));
+ }
+ }
+
/**
* 注册
* @param Request $request
@@ -180,7 +255,7 @@ class UserController
if (Util::isEmpty($language)) {
return Util::fail([], 'language' . trans('not_null'));
}
- if (!in_array($language,['en','zh_CN'])) {
+ if (!in_array($language, ['en', 'zh_CN'])) {
return Util::fail([], trans('param_error'));
}
$data = [
diff --git a/resource/translations/en/messages.php b/resource/translations/en/messages.php
index f989337..a618b4d 100644
--- a/resource/translations/en/messages.php
+++ b/resource/translations/en/messages.php
@@ -22,4 +22,5 @@ return [
'contacts_not_null' => ' Contact person, email, and phone cannot be empty at the same time',
'car_type_not_null' => ' preference_not_null',
'channel_not_null' => ' channel not null',
+ 'email_consistent' => ' Inconsistent email addresses',
];
\ No newline at end of file
diff --git a/resource/translations/zh_CN/messages.php b/resource/translations/zh_CN/messages.php
index f3d14b5..12f04cf 100644
--- a/resource/translations/zh_CN/messages.php
+++ b/resource/translations/zh_CN/messages.php
@@ -22,4 +22,5 @@ return [
'contacts_not_null' => ' 联系人,邮箱,电话不能同时为空',
'car_type_not_null' => ' 偏好不能为空',
'channel_not_null' => ' 渠道不能为空',
+ 'email_consistent' => ' 邮箱不一致',
];
\ No newline at end of file