don't force smtp username to be an email address

This commit is contained in:
wh1te909 2020-08-12 02:29:50 +00:00
parent d5c9d2acc7
commit 932cd8f3d3
4 changed files with 33 additions and 20 deletions

1
.gitignore vendored
View File

@ -33,3 +33,4 @@ app.ini
*.pem
create_services.py
gen_random.py
sync_salt_modules.py

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1 on 2020-08-12 02:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0005_auto_20200712_0454'),
]
operations = [
migrations.AlterField(
model_name='coresettings',
name='smtp_host_user',
field=models.CharField(blank=True, default='admin@example.com', max_length=255, null=True),
),
]

View File

@ -25,8 +25,8 @@ class CoreSettings(models.Model):
smtp_host = models.CharField(
max_length=255, null=True, blank=True, default="smtp.gmail.com"
)
smtp_host_user = models.EmailField(
null=True, blank=True, default="admin@example.com"
smtp_host_user = models.CharField(
max_length=255, null=True, blank=True, default="admin@example.com"
)
smtp_host_password = models.CharField(
max_length=255, null=True, blank=True, default="changeme"

View File

@ -108,13 +108,7 @@
<q-card-section class="row">
<div class="col-2">Username:</div>
<div class="col-4"></div>
<q-input
outlined
dense
v-model="settings.smtp_host_user"
class="col-6"
:rules="[val => isValidEmail(val) || 'Invalid email']"
/>
<q-input outlined dense v-model="settings.smtp_host_user" class="col-6" />
</q-card-section>
<q-card-section class="row">
<div class="col-2">Password:</div>
@ -200,13 +194,13 @@ export default {
borderRadius: "5px",
backgroundColor: "#027be3",
width: "5px",
opacity: 0.75
}
opacity: 0.75,
},
};
},
methods: {
getCoreSettings() {
axios.get("/core/getcoresettings/").then(r => {
axios.get("/core/getcoresettings/").then((r) => {
this.settings = r.data;
this.allTimezones = Object.freeze(r.data.all_timezones);
this.ready = true;
@ -218,19 +212,19 @@ export default {
title: "Add email",
prompt: {
model: "",
isValid: val => this.isValidEmail(val),
type: "email"
isValid: (val) => this.isValidEmail(val),
type: "email",
},
cancel: true,
ok: { label: "Add", color: "primary" },
persistent: false
persistent: false,
})
.onOk(data => {
.onOk((data) => {
this.settings.email_alert_recipients.push(data);
});
},
removeEmail(email) {
const removed = this.settings.email_alert_recipients.filter(k => k !== email);
const removed = this.settings.email_alert_recipients.filter((k) => k !== email);
this.settings.email_alert_recipients = removed;
},
isValidEmail(val) {
@ -241,7 +235,7 @@ export default {
this.$q.loading.show();
axios
.patch("/core/editsettings/", this.settings)
.then(r => {
.then((r) => {
this.$q.loading.hide();
this.notifySuccess("Settings were edited!");
this.$emit("close");
@ -250,10 +244,10 @@ export default {
this.$q.loading.hide();
this.notifyError("You have some invalid input. Please check all fields");
});
}
},
},
created() {
this.getCoreSettings();
}
},
};
</script>