Skip to content

Commit

Permalink
Merge pull request cachethq#2836 from CachetHQ/mail-validation
Browse files Browse the repository at this point in the history
Mail validation
  • Loading branch information
jbrooksuk authored Dec 3, 2017
2 parents 5b460d2 + 11785e4 commit fe154be
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function postStep1()
});

$v->sometimes(['env.mail_address', 'env.mail_username', 'env.mail_password'], 'required', function ($input) {
return $input->env['mail_driver'] !== 'log';
return !in_array($input->env['mail_driver'], ['log', 'smtp']);
});

if ($v->passes()) {
Expand Down
2 changes: 1 addition & 1 deletion public/dist/css/dashboard/dashboard.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions public/dist/js/all.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/dist/js/app.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions resources/assets/js/components/Setup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
cache_driver: null,
queue_driver: null,
session_driver: null,
mail_driver: null,
mail_driver: 'smtp',
},
mail: {
host: null,
Expand All @@ -19,8 +19,8 @@ module.exports = {
password: null,
requiresHost: true,
requiresUsername: true,
requiresPassword: true,
requiresUsername: false,
requiresPassword: false,
},
system: {
name: null,
Expand All @@ -40,6 +40,10 @@ module.exports = {
this.mail.requiresHost = false
this.mail.requiresUsername = true
this.mail.requiresPassword = true
} else if (driver === 'smtp') {
this.mail.requiresHost = true
this.mail.requiresUsername = false
this.mail.requiresPassword = false
} else {
this.mail.requiresHost = true
this.mail.requiresUsername = true
Expand Down
14 changes: 7 additions & 7 deletions resources/views/setup/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
<span class="text-danger">{{ $errors->first('env.mail_driver') }}</span>
@endif
</div>
<div class="form-group" v-if="mail.requiresHost">
<label>{{ trans('forms.setup.mail_host') }} (optional)</label>
<input type="text" class="form-control" name="env[mail_host]" value="{{ Binput::old('env.mail_host', $mail_config['host']) }}" placeholder="{{ trans('forms.setup.mail_host') }}">
<div class="form-group">
<label>{{ trans('forms.setup.mail_host') }}</label>
<input type="text" class="form-control" name="env[mail_host]" value="{{ Binput::old('env.mail_host', $mail_config['host']) }}" placeholder="{{ trans('forms.setup.mail_host') }}" :required="mail.requiresHost">
@if($errors->has('env.mail_host'))
<span class="text-danger">{{ $errors->first('env.mail_host') }}</span>
@endif
Expand All @@ -100,16 +100,16 @@
<span class="text-danger">{{ $errors->first('env.mail_address') }}</span>
@endif
</div>
<div class="form-group" v-if="mail.requiresUsername">
<div class="form-group">
<label>{{ trans('forms.setup.mail_username') }}</label>
<input type="text" class="form-control" name="env[mail_username]" value="{{ Binput::old('env.mail_username', $mail_config['username']) }}" placeholder="{{ trans('forms.setup.mail_username') }}">
<input type="text" class="form-control" name="env[mail_username]" value="{{ Binput::old('env.mail_username', $mail_config['username']) }}" placeholder="{{ trans('forms.setup.mail_username') }}" :required="mail.requiresUsername">
@if($errors->has('env.mail_username'))
<span class="text-danger">{{ $errors->first('env.mail_username') }}</span>
@endif
</div>
<div class="form-group" v-if="mail.requiresPassword">
<div class="form-group">
<label>{{ trans('forms.setup.mail_password') }}</label>
<input type="password" class="form-control" name="env[mail_password]" value="{{ Binput::old('env.mail_password', $mail_config['password']) }}" autocomplete="off" placeholder="{{ trans('forms.setup.mail_password') }}">
<input type="password" class="form-control" name="env[mail_password]" value="{{ Binput::old('env.mail_password', $mail_config['password']) }}" autocomplete="off" placeholder="{{ trans('forms.setup.mail_password') }}" :required="mail.requiresUsername">
@if($errors->has('env.mail_password'))
<span class="text-danger">{{ $errors->first('env.mail_password') }}</span>
@endif
Expand Down

0 comments on commit fe154be

Please sign in to comment.