使用fdesk库

This commit is contained in:
2025-07-23 16:55:18 +08:00
parent fa4ade4b35
commit ef66ecbbef
13 changed files with 71 additions and 39 deletions
+29 -8
View File
@@ -6,12 +6,14 @@ use app\model\Country;
use app\model\FeishuUser;
use app\model\User;
use app\model\UserSn;
use app\service\AuthService;
use app\service\MailService;
use app\service\UserService;
use app\util\HttpClient;
use app\util\JwtUtil;
use app\util\Util;
use config\constants\Constants;
use support\exception\BusinessException;
use support\Log;
use support\Redis;
use support\Request;
@@ -35,10 +37,14 @@ class UserController
return Util::fail([], trans('required_not_null'));
}
$user = User::select(['id', 'name', 'sex', 'role', 'avatar', 'email', 'password'])
->where('status', 0)
->where('email', $request->post('email'))
$user = User::where('status', 0)
// ->where('email', $request->post('email'))
->OrWhere(['email' => $request->post('email'),'phone' => $request->post('email')])
->first();
// $builder = User::where('status', 0)
// ->where('email', $request->post('email'));
// $sql = str_replace(['?'], ['\'%s\''], $builder->toSql());
// $fullSql = vsprintf($sql, $builder->getBindings());
if (!$user) {
return Util::fail(['user' => $user], trans('user_none'));
}
@@ -52,10 +58,15 @@ class UserController
//验证密码
// if (!password_verify($userPassword, $hashedPassword)) {
// if ($userPassword == $hashedPassword) {
if (!password_verify($password, $userPassword)) {
locale($language);
return Util::fail([], trans('password_error'));
}
if ($user['status'] != 1) {
return Util::fail([], '账号已禁用',403);
}
$userId = $user['id']; // 实际从数据库获取
@@ -66,7 +77,7 @@ class UserController
$result = $user;
unset($result['password']);
$result['token'] = $token;
$result['feishu_openid'] = FeishuUser::where('user_id', $userId)->value('open_id');
// $result['feishu_openid'] = FeishuUser::where('user_id', $userId)->value('open_id');
if (!Util::isEmpty($language)) {
User::where('id', $userId)
@@ -77,6 +88,17 @@ class UserController
return Util::success($result, trans('login_success'));
}
public function loginNew(Request $request)
{
try {
$authService = new AuthService();
$result = $authService->uPwdLogin($request->all());
return Util::success($result, '登录成功');
} catch (\Throwable $e) {
Util::fail([],$e->getMessage());
}
}
/**
* 发送邮箱验证码
* @param Request $request
@@ -152,14 +174,13 @@ class UserController
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
$data = [
'mobile' => $mobile,
'phone' => $mobile,
'email' => $email,
'name' => '用户_'.rand(111111, 999999),
'sex' => $sex,
'role' => 1,
'password' => $hashedPassword,
'status' => 0,
'avatar' => 'lingke_crm/logo.png'
'status' => 1,
'avatar' => ''
];