mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 14:34:21 +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">
|
||||
<label>
|
||||
<input id="mail_useauth" name="mail_useauth" type="checkbox" {% if mail_useauth %}checked{% endif %}>
|
||||
Use SMTP Authentication?
|
||||
Specify Username and Password
|
||||
</label>
|
||||
</div>
|
||||
<div id="mail_username_password">
|
||||
<div class="form-group">
|
||||
<label for="start">Username:</label>
|
||||
<input class="form-control" id='mail_username' name='mail_username' type='text'
|
||||
@@ -149,6 +150,7 @@
|
||||
placeholder="Password"
|
||||
{% if mail_password is defined and mail_password != None %}value="{{ mail_password }}"{% endif %}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input id="mail_ssl" name="mail_ssl" type="checkbox" {% if mail_ssl %}checked{% endif %}>
|
||||
@@ -606,7 +608,6 @@
|
||||
});
|
||||
|
||||
$(function () {
|
||||
|
||||
var hash = window.location.hash;
|
||||
if (hash) {
|
||||
hash = hash.replace("<>[]'\"", "");
|
||||
@@ -621,8 +622,7 @@
|
||||
var start = $('#start').val();
|
||||
var end = $('#end').val();
|
||||
var freeze = $('#freeze').val();
|
||||
console.log(start);
|
||||
console.log(end);
|
||||
|
||||
if (start){
|
||||
load_timestamp('start', start);
|
||||
}
|
||||
@@ -632,6 +632,11 @@
|
||||
if (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>
|
||||
{% endblock %}
|
||||
|
||||
@@ -437,11 +437,14 @@ def mailserver():
|
||||
|
||||
|
||||
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.ehlo()
|
||||
else:
|
||||
smtp = smtplib.SMTP_SSL(host, port)
|
||||
|
||||
if TLS:
|
||||
smtp.starttls()
|
||||
smtp.ehlo()
|
||||
|
||||
if auth:
|
||||
smtp.login(username, password)
|
||||
return smtp
|
||||
|
||||
Reference in New Issue
Block a user