alroyso 5 月之前
父節點
當前提交
bf3a8932dc
共有 3 個文件被更改,包括 9 次插入0 次删除
  1. 7 0
      app/Http/Controllers/UserController.php
  2. 1 0
      resources/lang/en/common.php
  3. 1 0
      resources/lang/zh-CN/common.php

+ 7 - 0
app/Http/Controllers/UserController.php

@@ -199,6 +199,13 @@ class UserController extends Controller
 //                    return Redirect::back()->withErrors(trans('common.update_action', ['action' => trans('common.failed_code')]));
 //                }
 
+                $email = $data['newemail'];
+                $pattern = "/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/";
+
+                if (!preg_match($pattern, $email)) {
+                    return Redirect::back()->withErrors(trans('common.update_action', ['action' => trans('common.error_email')]));
+                }
+
                 if ( User::where('email', $data['newemail'])->count() >= 1) {
                     return Redirect::back()->withErrors(trans('common.update_action', ['action' => trans('common.failed_email')]));
                 }

+ 1 - 0
resources/lang/en/common.php

@@ -40,6 +40,7 @@ return [
     'success'        => 'Successfully',
     'failed'         => 'Failed',
     'failed_email'         => 'Failed email is exists ',
+    'error_email'         => 'The mailbox format is not correct  ',
     'update'         => 'Update',
     'update_action'  => 'Update :action',
     'none'           => 'None',

+ 1 - 0
resources/lang/zh-CN/common.php

@@ -40,6 +40,7 @@ return [
     'success'        => '成功',
     'failed'         => '失败',
     'failed_email'         => '失败邮箱存在',
+    'error_email'         => '邮箱格式不对',
     'failed_code'         => '验证码失败',
     'update'         => '更 新',
     'update_action'  => '更新:action',