Skip to content

Commit

Permalink
Addressed merge issue for reset password for snipe#7997
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <snipe@snipe.net>
  • Loading branch information
snipe committed May 1, 2020
1 parent 82e0249 commit 8bb3c01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
16 changes: 7 additions & 9 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ public function getEmailSubject()
*/
public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['username' => 'required'], ['username.required' => 'Please enter your username.']);

/**
* Let's set a max character count here to prevent potential
* buffer overflow issues with attackers sending very large
* payloads through.
*/
$this->validate($request, ['email' => 'required|email|max:250']);
$this->validate($request->validate([
'email' => 'required|email|max:255']));


/**
* If we find a matching email with an activated user, we will
Expand All @@ -70,16 +71,16 @@ public function sendResetLinkEmail(Request $request)
*/
$response = $this->broker()->sendResetLink(
array_merge(
$request->only('username'),
$request->only('email'),
['activated' => '1'],
['ldap_import' => '0']
)
);

if ($response === \Password::RESET_LINK_SENT) {
\Log::info('Password reset attempt: User '.$request->input('username').' found, password reset sent');
\Log::info('Password reset attempt: User '.$request->input('email').' found, password reset sent');
} else {
\Log::info('Password reset attempt: User '.$request->input('username').' not found or user is inactive');
\Log::info('Password reset attempt: User '.$request->input('email').' not found or user is inactive');
}


Expand All @@ -101,8 +102,5 @@ public function sendResetLinkEmail(Request $request)
return redirect()->route('login')->with('success',trans('passwords.sent'));
}

return back()->withErrors(
['email' => trans($response)]
);
}

}
5 changes: 2 additions & 3 deletions resources/views/auth/passwords/email.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@



<div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">

<div class="col-md-12">
<input type="text" class="form-control" name="username" value="{{ old('username') }}" placeholder="{{ trans('admin/users/table.username') }}">
<input type="email" class="form-control" name="email" value="{{ old('email') }}" placeholder="{{ trans('admin/users/table.email') }}" aria-label="email">
{!! $errors->first('username', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
{!! $errors->first('email', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
</div>
</div>

Expand Down

0 comments on commit 8bb3c01

Please sign in to comment.