Skip to content

Commit

Permalink
Merge pull request doccano#504 from CatalystCode/enhancement/verifica…
Browse files Browse the repository at this point in the history
…tion-emails-on-azure

Enhancement/Verification emails on Azure
  • Loading branch information
Hironsan authored Jan 10, 2020
2 parents ed388db + dc2e264 commit 5942bbf
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 11 deletions.
18 changes: 9 additions & 9 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@
'endpoint': env('AZURE_APPINSIGHTS_ENDPOINT', None),
}

## necessary for email verification setup
# EMAIL_USE_TLS = True
# EMAIL_HOST = 'smtp.gmail.com'
# EMAIL_HOST_USER = '[email protected]'
# EMAIL_HOST_PASSWORD = 'gfds6jk#4ljIr%G8%'
# EMAIL_PORT = 587
#
## During development only
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# necessary for email verification of new accounts
EMAIL_USE_TLS = env.bool('EMAIL_USE_TLS', False)
EMAIL_HOST = env('EMAIL_HOST', None)
EMAIL_HOST_USER = env('EMAIL_HOST_USER', None)
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD', None)
EMAIL_PORT = env.int('EMAIL_PORT', 587)

if not EMAIL_HOST:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
4 changes: 2 additions & 2 deletions app/authentification/templates/acc_active_email.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% autoescape off %}
Hi {{ user.username }},
Please click on the link to confirm your email,
http://{{ domain }}{% url 'activate' uidb64=uid token=token %}
Please click on the link to confirm your email and activate your Doccano account:
{{ scheme }}://{{ domain }}{% url 'activate' uidb64=uid token=token %}
{% endautoescape %}
1 change: 1 addition & 0 deletions app/authentification/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def post(self, request, *args, **kwargs):
message = render_to_string('acc_active_email.html', {
'user': user,
'domain': current_site.domain,
'scheme': request.scheme,
'uid': urlsafe_base64_encode(force_bytes(user.pk)).decode(),
'token': account_activation_token.make_token(user),
})
Expand Down
55 changes: 55 additions & 0 deletions azuredeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"adminPassword": {
"type": "securestring",
"minLength": 16,
"maxLength": 50,
"metadata": {
"description": "The password for the admin account."
}
Expand All @@ -52,6 +53,21 @@
"description": "The SKU of the webapp hosting tier."
}
},
"sendgridSku": {
"type": "string",
"defaultValue": "free",
"allowedValues": [
"free",
"bronze",
"silver",
"gold",
"platinum",
"premier"
],
"metadata": {
"description": "The SKU of the Sendgrid email account."
}
},
"databaseCores": {
"type": "int",
"defaultValue": 2,
Expand Down Expand Up @@ -124,11 +140,29 @@
"databaseUserCredentials" : "[concat(uriComponent(concat(parameters('adminUserName'), '@', variables('databaseServerName'))), ':', parameters('adminPassword'))]",
"databaseFqdn" : "[concat( variables('databaseServerName'), '.postgres.database.azure.com:', variables('databaseServerPort'))]",
"databaseConnectionString": "[concat('pgsql://', variables('databaseUserCredentials'), '@', variables('databaseFqdn'), '/', parameters('databaseName'))]",
"sendgridAccountName": "[concat(parameters('appName'),'-email')]",
"appServicePlanName": "[concat(parameters('appName'),'-hosting')]",
"analyticsName": "[concat(parameters('appName'),'-analytics')]",
"appFqdn": "[concat(parameters('appName'),'.azurewebsites.net')]"
},
"resources": [
{
"name": "[variables('sendgridAccountName')]",
"type": "Sendgrid.Email/accounts",
"apiVersion": "2015-01-01",
"location": "[variables('location')]",
"plan": {
"name": "[parameters('sendgridSku')]",
"publisher": "Sendgrid",
"product": "sendgrid_azure",
"promotionCode": ""
},
"properties": {
"acceptMarketingEmails": false,
"email": "[parameters('adminContactEmail')]",
"password": "[parameters('adminPassword')]"
}
},
{
"type": "Microsoft.Insights/components",
"apiVersion": "2015-05-01",
Expand Down Expand Up @@ -207,6 +241,7 @@
"kind": "app,linux,container",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName'))]",
"[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]",
"[resourceId('Microsoft.Insights/components', variables('analyticsName'))]",
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
Expand Down Expand Up @@ -261,6 +296,26 @@
"name": "ADMIN_PASSWORD",
"value": "[parameters('adminPassword')]"
},
{
"name": "EMAIL_USE_TLS",
"value": "True"
},
{
"name": "EMAIL_HOST",
"value": "[reference(resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName'))).smtpServer]"
},
{
"name": "EMAIL_HOST_USER",
"value": "[reference(resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName'))).username]"
},
{
"name": "EMAIL_HOST_PASSWORD",
"value": "[parameters('adminPassword')]"
},
{
"name": "EMAIL_PORT",
"value": "587"
},
{
"name": "DEBUG",
"value": "False"
Expand Down

0 comments on commit 5942bbf

Please sign in to comment.