Fix updating email address
Add detecting whether email is existed or not
This commit is contained in:
parent
b54ddb6fb2
commit
97bcfa2686
@ -214,6 +214,10 @@ class AdminController extends Controller
|
||||
'email' => 'required|email'
|
||||
]);
|
||||
|
||||
if ($users->get($request->input('email'), 'email')) {
|
||||
return json(trans('admin.users.operations.email.existed', ['email' => $request->input('email')]), 1);
|
||||
}
|
||||
|
||||
$user->setEmail($request->input('email'));
|
||||
|
||||
return json(trans('admin.users.operations.email.success'), 0);
|
||||
|
@ -90,9 +90,9 @@ class UserController extends Controller
|
||||
* Handle changing user profile.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return void
|
||||
* @return mixed
|
||||
*/
|
||||
public function handleProfile(Request $request)
|
||||
public function handleProfile(Request $request, UserRepository $users)
|
||||
{
|
||||
$action = $request->input('action', '');
|
||||
|
||||
@ -129,6 +129,10 @@ class UserController extends Controller
|
||||
'password' => 'required|min:8|max:16'
|
||||
]);
|
||||
|
||||
if ($users->get($request->input('new_email'), 'email')) {
|
||||
return json(trans('user.profile.email.existed'), 1);
|
||||
}
|
||||
|
||||
if (!$this->user->verifyPassword($request->input('password')))
|
||||
return json(trans('user.profile.email.wrong-password'), 1);
|
||||
|
||||
|
@ -17,6 +17,7 @@ users:
|
||||
non-existent: No such user.
|
||||
email:
|
||||
change: Edit Email
|
||||
existed: :email is existed.
|
||||
success: Email changed successfully.
|
||||
nickname:
|
||||
change: Edit Nickname
|
||||
|
@ -127,6 +127,7 @@ profile:
|
||||
password: Current Password
|
||||
button: Change Email
|
||||
wrong-password: Wrong password.
|
||||
existed: This email address is used.
|
||||
success: Email address updated successfully, please log in again.
|
||||
|
||||
delete:
|
||||
|
@ -17,6 +17,7 @@ users:
|
||||
non-existent: 用户不存在
|
||||
email:
|
||||
change: 修改邮箱
|
||||
existed: :email 已被占用
|
||||
success: 邮箱修改成功
|
||||
nickname:
|
||||
change: 修改昵称
|
||||
|
@ -134,6 +134,7 @@ profile:
|
||||
password: 当前密码
|
||||
button: 修改邮箱
|
||||
wrong-password: 密码错误
|
||||
existed: 这个邮箱已经被别人占用啦
|
||||
success: 邮箱修改成功,请重新登录
|
||||
|
||||
delete:
|
||||
|
Loading…
Reference in New Issue
Block a user