Showing
1 changed file
with
15 additions
and
3 deletions
| ... | ... | @@ -53,16 +53,28 @@ class AuthService |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // 3. 查找或创建用户 |
| 56 | - $user = $this->findOrCreateUser($phone, $openid, $unionid); | |
| 56 | + try { | |
| 57 | + $user = $this->findOrCreateUser($phone, $openid, $unionid); | |
| 58 | + } catch (Exception $e) { | |
| 59 | + $this->logDebug("Exception in findOrCreateUser: " . $e->getMessage()); | |
| 60 | + return ['ok' => false, 'error' => 'Database Error: ' . $e->getMessage()]; | |
| 61 | + } | |
| 62 | + | |
| 57 | 63 | if (!$user) { |
| 58 | - $this->logDebug("Error: Failed to find/create user"); | |
| 64 | + $this->logDebug("Error: Failed to find/create user (Result is null)"); | |
| 59 | 65 | return ['ok' => false, 'error' => '用户创建失败']; |
| 60 | 66 | } |
| 61 | 67 | |
| 62 | 68 | $this->logDebug("User ID: " . $user['id']); |
| 63 | 69 | |
| 64 | 70 | // 4. 创建 Session |
| 65 | - $token = $this->createSession($user['id']); | |
| 71 | + try { | |
| 72 | + $token = $this->createSession($user['id']); | |
| 73 | + } catch (Exception $e) { | |
| 74 | + $this->logDebug("Exception in createSession: " . $e->getMessage()); | |
| 75 | + return ['ok' => false, 'error' => 'Session Error: ' . $e->getMessage()]; | |
| 76 | + } | |
| 77 | + | |
| 66 | 78 | if (!$token) { |
| 67 | 79 | $this->logDebug("Error: Failed to create session"); |
| 68 | 80 | return ['ok' => false, 'error' => 'Session 创建失败']; | ... | ... |
Please
register
or
login
to post a comment