正在显示
2 个修改的文件
包含
47 行增加
和
41 行删除
@@ -37,47 +37,43 @@ class Home { | @@ -37,47 +37,43 @@ class Home { | ||
37 | app()->e('smtp_verify_error'); | 37 | app()->e('smtp_verify_error'); |
38 | } | 38 | } |
39 | 39 | ||
40 | - $data = db()->first(\Model\email::first($formData['email'])); | ||
41 | - | ||
42 | - app()->_json($data); | ||
43 | - | ||
44 | -// // host | ||
45 | -// $model = Email::_first($formData['email']); | ||
46 | -// if(!$model){ | ||
47 | -// $model = new Email(); | ||
48 | -// $model->email = $formData['email']; | ||
49 | -// } | ||
50 | -// | ||
51 | -// $model->imap = $formData['imap']; | ||
52 | -// $model->smtp = $formData['smtp']; | ||
53 | -// $model->status = Email::STATUS_ACTIVE; | ||
54 | -// $model->password = @base64_encode($formData['password']); | ||
55 | -// | ||
56 | -// try { | ||
57 | -// Mail::login($model->email,$model->password,$model->imap); | ||
58 | -// }catch (\Throwable $e){ | ||
59 | -// return res() | ||
60 | -// ->message($e->getMessage()) | ||
61 | -// ->status(400) | ||
62 | -// ->toJson(); | ||
63 | -// } | ||
64 | -// | ||
65 | -// // 登录成功了,密码验证字段通过 | ||
66 | -// $model->pwd_error = 0; | ||
67 | -// // 保存好邮箱 | ||
68 | -// $model->save(); | ||
69 | -// | ||
70 | -// // 设置上id,方便后面使用 | ||
71 | -// Mail::$client[$model->email]->setId($model->id); | ||
72 | -// | ||
73 | -// // 开始同步文件夹 | ||
74 | -//// $folder = Mail::syncFolder($model->email); | ||
75 | -// | ||
76 | -// return res() | ||
77 | -// ->data([ | ||
78 | -// 'token' => token_en($model->id.','.$model->email.','.time()) | ||
79 | -// ]) | ||
80 | -// ->toJson(); | 40 | + // 查询数据 |
41 | + $model = db()->first(\Model\email::first($formData['email'])); | ||
42 | + if(!$model){ | ||
43 | + $model = new Email(); | ||
44 | + $model->email = $formData['email']; | ||
45 | + } | ||
46 | + | ||
47 | + $model->imap = $formData['imap']; | ||
48 | + $model->smtp = $formData['smtp']; | ||
49 | + $model->status = Email::STATUS_ACTIVE; | ||
50 | + $model->password = @base64_encode($formData['password']); | ||
51 | + | ||
52 | + try { | ||
53 | + Mail::login($model->email,$model->password,$model->imap); | ||
54 | + }catch (\Throwable $e){ | ||
55 | + return res() | ||
56 | + ->message($e->getMessage()) | ||
57 | + ->status(400) | ||
58 | + ->toJson(); | ||
59 | + } | ||
60 | + | ||
61 | + // 登录成功了,密码验证字段通过 | ||
62 | + $model->pwd_error = 0; | ||
63 | + // 保存好邮箱 | ||
64 | + $model->save(); | ||
65 | + | ||
66 | + // 设置上id,方便后面使用 | ||
67 | + Mail::$client[$model->email]->setId($model->id); | ||
68 | + | ||
69 | + // 开始同步文件夹 | ||
70 | +// $folder = Mail::syncFolder($model->email); | ||
71 | + | ||
72 | + return res() | ||
73 | + ->data([ | ||
74 | + 'token' => token_en($model->id.','.$model->email.','.time()) | ||
75 | + ]) | ||
76 | + ->toJson(); | ||
81 | 77 | ||
82 | } | 78 | } |
83 | 79 |
-
请 注册 或 登录 后发表评论