Skip to content

Commit

Permalink
Merge pull request #11063 from snipe/fixes/set_maxlength_for_user_fields
Browse files Browse the repository at this point in the history
Sets maxlength of user fields to 191
  • Loading branch information
snipe committed May 13, 2022
2 parents c3e8c35 + deb2d95 commit cf4b418
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
8 changes: 4 additions & 4 deletions app/Models/User.php
Expand Up @@ -75,12 +75,12 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
*/

protected $rules = [
'first_name' => 'required|string|min:1',
'username' => 'required|string|min:1|unique_undeleted',
'email' => 'email|nullable',
'first_name' => 'required|string|min:1|max:191',
'username' => 'required|string|min:1|unique_undeleted|max:191',
'email' => 'email|nullable|max:191',
'password' => 'required|min:8',
'locale' => 'max:10|nullable',
'website' => 'url|nullable',
'website' => 'url|nullable|max:191',
'manager_id' => 'nullable|exists:users,id|cant_manage_self',
'location_id' => 'exists:locations,id|nullable',
];
Expand Down
16 changes: 10 additions & 6 deletions resources/views/users/edit.blade.php
Expand Up @@ -87,7 +87,7 @@
<div class="form-group {{ $errors->has('first_name') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="first_name">{{ trans('general.first_name') }}</label>
<div class="col-md-6{{ (Helper::checkIfRequired($user, 'first_name')) ? ' required' : '' }}">
<input class="form-control" type="text" name="first_name" id="first_name" value="{{ old('first_name', $user->first_name) }}" />
<input class="form-control" type="text" name="first_name" id="first_name" value="{{ old('first_name', $user->first_name) }}" maxlength=191" />
{!! $errors->first('first_name', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
Expand All @@ -96,7 +96,7 @@
<div class="form-group {{ $errors->has('last_name') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="last_name">{{ trans('general.last_name') }} </label>
<div class="col-md-6{{ (Helper::checkIfRequired($user, 'last_name')) ? ' required' : '' }}">
<input class="form-control" type="text" name="last_name" id="last_name" value="{{ old('last_name', $user->last_name) }}" />
<input class="form-control" type="text" name="last_name" id="last_name" value="{{ old('last_name', $user->last_name) }}" maxlength=191" />
{!! $errors->first('last_name', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
Expand All @@ -113,6 +113,7 @@ class="form-control"
id="username"
value="{{ Request::old('username', $user->username) }}"
autocomplete="off"
maxlength=191"
readonly
onfocus="this.removeAttribute('readonly');"
{{ ((config('app.lock_passwords') && ($user->id)) ? ' disabled' : '') }}
Expand Down Expand Up @@ -235,6 +236,7 @@ class="form-control"
type="text"
name="email"
id="email"
maxlength=191"
value="{{ Request::old('email', $user->email) }}"
{{ ((config('app.lock_passwords') && ($user->id)) ? ' disabled' : '') }}
autocomplete="off"
Expand Down Expand Up @@ -307,6 +309,7 @@ class="form-control"
type="text"
aria-label="employee_num"
name="employee_num"
maxlength=191"
id="employee_num"
value="{{ Request::old('employee_num', $user->employee_num) }}"
/>
Expand All @@ -322,6 +325,7 @@ class="form-control"
<input
class="form-control"
type="text"
maxlength=191"
name="jobtitle"
id="jobtitle"
value="{{ Request::old('jobtitle', $user->jobtitle) }}"
Expand Down Expand Up @@ -358,7 +362,7 @@ class="form-control"
<div class="form-group {{ $errors->has('phone') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="phone">{{ trans('admin/users/table.phone') }}</label>
<div class="col-md-6">
<input class="form-control" type="text" name="phone" id="phone" value="{{ old('phone', $user->phone) }}" />
<input class="form-control" type="text" name="phone" id="phone" value="{{ old('phone', $user->phone) }}" maxlength=191" />
{!! $errors->first('phone', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
Expand All @@ -367,7 +371,7 @@ class="form-control"
<div class="form-group {{ $errors->has('website') ? ' has-error' : '' }}">
<label for="website" class="col-md-3 control-label">{{ trans('general.website') }}</label>
<div class="col-md-6">
<input class="form-control" type="text" name="website" id="website" value="{{ old('website', $user->website) }}" />
<input class="form-control" type="text" name="website" id="website" value="{{ old('website', $user->website) }}" maxlength=191" />
{!! $errors->first('website', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
Expand All @@ -376,7 +380,7 @@ class="form-control"
<div class="form-group{{ $errors->has('address') ? ' has-error' : '' }}">
<label class="col-md-3 control-label" for="address">{{ trans('general.address') }}</label>
<div class="col-md-6">
<input class="form-control" type="text" name="address" id="address" value="{{ old('address', $user->address) }}" />
<input class="form-control" type="text" name="address" id="address" value="{{ old('address', $user->address) }}" maxlength=191" />
{!! $errors->first('address', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
Expand All @@ -385,7 +389,7 @@ class="form-control"
<div class="form-group{{ $errors->has('city') ? ' has-error' : '' }}">
<label class="col-md-3 control-label" for="city">{{ trans('general.city') }}</label>
<div class="col-md-6">
<input class="form-control" type="text" name="city" id="city" aria-label="city" value="{{ old('city', $user->city) }}" />
<input class="form-control" type="text" name="city" id="city" aria-label="city" value="{{ old('city', $user->city) }}" maxlength=191" />
{!! $errors->first('city', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
Expand Down

0 comments on commit cf4b418

Please sign in to comment.