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