Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
obinnaelviso committed Jan 8, 2024
1 parent 26c0c9e commit c8ea8ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Http/Controllers/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ public function account_onSave()
$passwordChanged = strlen(post('User[password]'));
$languageChanged = $this->currentUser->language != post('User[language_id]');
$emailChanged = $this->currentUser->email != post('User[email]');
if ($emailChanged) {
if ($emailChanged || $passwordChanged) {
AdminAuth::logout();
return redirect('/admin/login');
return redirect('/logout');
}
if ($usernameChanged || $passwordChanged || $languageChanged) {
if ($usernameChanged || $languageChanged) {
$this->currentUser->reload()->reloadRelations();
AdminAuth::login($this->currentUser, true);
}
Expand Down
11 changes: 9 additions & 2 deletions src/Requests/UserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

class UserRequest extends FormRequest
{

protected function getRecordId()
{
$slugName = ($slug = $this->route('slug'))
? str_after($slug, '/') : null;
return $slugName == 'account' ? AdminAuth::id() : $slugName;
}
public function attributes()
{
return [
Expand All @@ -31,10 +38,10 @@ public function rules()
return [
'name' => ['required', 'string', 'between:2,255'],
'email' => ['required', 'max:96', 'email:filter',
Rule::unique('admin_users')->ignore(AdminAuth::id(), 'user_id'),
Rule::unique('admin_users')->ignore($this->getRecordId(), 'user_id'),
],
'username' => ['required', 'alpha_dash', 'between:2,32',
Rule::unique('admin_users')->ignore(AdminAuth::id(), 'user_id'),
Rule::unique('admin_users')->ignore($this->getRecordId(), 'user_id'),
],
'password' => ['sometimes', 'required_if:send_invite,0', 'string', 'between:6,32', 'same:password_confirm'],
'status' => ['boolean'],
Expand Down

0 comments on commit c8ea8ef

Please sign in to comment.