mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 22:44:24 +01:00
Toggle username_password inputs depending on mail_useauth and clean get_smtp util (#343)
This commit is contained in:
@@ -134,9 +134,10 @@
|
|||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
<input id="mail_useauth" name="mail_useauth" type="checkbox" {% if mail_useauth %}checked{% endif %}>
|
<input id="mail_useauth" name="mail_useauth" type="checkbox" {% if mail_useauth %}checked{% endif %}>
|
||||||
Use SMTP Authentication?
|
Specify Username and Password
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="mail_username_password">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="start">Username:</label>
|
<label for="start">Username:</label>
|
||||||
<input class="form-control" id='mail_username' name='mail_username' type='text'
|
<input class="form-control" id='mail_username' name='mail_username' type='text'
|
||||||
@@ -149,6 +150,7 @@
|
|||||||
placeholder="Password"
|
placeholder="Password"
|
||||||
{% if mail_password is defined and mail_password != None %}value="{{ mail_password }}"{% endif %}>
|
{% if mail_password is defined and mail_password != None %}value="{{ mail_password }}"{% endif %}>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
<input id="mail_ssl" name="mail_ssl" type="checkbox" {% if mail_ssl %}checked{% endif %}>
|
<input id="mail_ssl" name="mail_ssl" type="checkbox" {% if mail_ssl %}checked{% endif %}>
|
||||||
@@ -606,7 +608,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
var hash = window.location.hash;
|
var hash = window.location.hash;
|
||||||
if (hash) {
|
if (hash) {
|
||||||
hash = hash.replace("<>[]'\"", "");
|
hash = hash.replace("<>[]'\"", "");
|
||||||
@@ -621,8 +622,7 @@
|
|||||||
var start = $('#start').val();
|
var start = $('#start').val();
|
||||||
var end = $('#end').val();
|
var end = $('#end').val();
|
||||||
var freeze = $('#freeze').val();
|
var freeze = $('#freeze').val();
|
||||||
console.log(start);
|
|
||||||
console.log(end);
|
|
||||||
if (start){
|
if (start){
|
||||||
load_timestamp('start', start);
|
load_timestamp('start', start);
|
||||||
}
|
}
|
||||||
@@ -632,6 +632,11 @@
|
|||||||
if (freeze) {
|
if (freeze) {
|
||||||
load_timestamp('freeze', freeze);
|
load_timestamp('freeze', freeze);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Toggle username and password based on stored value
|
||||||
|
$('#mail_useauth').change(function () {
|
||||||
|
$('#mail_username_password').toggle(this.checked);
|
||||||
|
}).change();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -437,11 +437,14 @@ def mailserver():
|
|||||||
|
|
||||||
|
|
||||||
def get_smtp(host, port, username=None, password=None, TLS=None, SSL=None, auth=None):
|
def get_smtp(host, port, username=None, password=None, TLS=None, SSL=None, auth=None):
|
||||||
|
if SSL is None:
|
||||||
smtp = smtplib.SMTP(host, port)
|
smtp = smtplib.SMTP(host, port)
|
||||||
smtp.ehlo()
|
else:
|
||||||
|
smtp = smtplib.SMTP_SSL(host, port)
|
||||||
|
|
||||||
if TLS:
|
if TLS:
|
||||||
smtp.starttls()
|
smtp.starttls()
|
||||||
smtp.ehlo()
|
|
||||||
if auth:
|
if auth:
|
||||||
smtp.login(username, password)
|
smtp.login(username, password)
|
||||||
return smtp
|
return smtp
|
||||||
|
|||||||
Reference in New Issue
Block a user