Skip to content

Commit

Permalink
Feature/confirm registration (#48)
Browse files Browse the repository at this point in the history
* - added email templates to api project
- added email configuration to appsettings
- added send email after registering a user
- added confirmation endpoint

* created confirmation html page

* cleanup

* cleanup: remove jurnal medical refs from templates

* cleanup

* cleanup

* added user api to dockerfile
fix build

* cleanup template

* - remove identityserver project
- add confirmation message after email is confirmed

Co-authored-by: trupci <a.trupcea@moodmedia.com>
  • Loading branch information
trupci and atrupcea committed Apr 28, 2021
1 parent 4328ed4 commit f0379d5
Show file tree
Hide file tree
Showing 230 changed files with 263 additions and 57,173 deletions.
1 change: 1 addition & 0 deletions Src/DeUrgenta.Api/DeUrgenta.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="Hellang.Middleware.ProblemDetails" Version="5.3.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
Expand Down
33 changes: 33 additions & 0 deletions Src/DeUrgenta.Api/EmailTemplates/accountConfirmationTemplate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Bine ai venit!</title>
<style>
</style>
</head>
<body class="">
<span ></span>
<section>
<div>
<img alt="Code for Romania" src="" style="float: right" height="32">
<div style="clear:both;"></div>
</div>
</section>
<span></span>
<section>
<p>
Salut!
</p>
<p>
Contul tău a fost creat, dar pentru a putea să te loghezi trebuie să confirmi contul tău apăsând pe <a href='%%confirmationLink%%'>acest link</a>.
</p>
<p>
Îți mulțumim,
<br />
Echipa De Urgenta
</p>
</section>
</body>
</html>
28 changes: 28 additions & 0 deletions Src/DeUrgenta.Api/EmailTemplates/resetPasswordTemplate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Bine ai venit!</title>
<style>
</style>
</head>
<body class="">
<span ></span>
<section>
<div>
<img alt="Code for Romania" src="" style="float: right" height="32">
<div style="clear:both;"></div>
</div>
</section>
<span></span>
<section>
<p>
Salut!
</p>
<p>
Pentru a-ți reseta parola apasă pe <a href='%%resetPasswordLink%%'>acest link</a>.
</p>
</section>
</body>
</html>
5 changes: 3 additions & 2 deletions Src/DeUrgenta.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;

namespace DeUrgenta.Api
{
Expand Down Expand Up @@ -51,7 +52,7 @@ public void ConfigureServices(IServiceCollection services)
.AllowAnyMethod()
.AllowAnyHeader();
}));

services.SetupEmailService(Configuration);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -72,7 +73,7 @@ public void Configure(IApplicationBuilder app)
app.UseAuthorization();
app.UseEndpoints(endpoints => endpoints.MapControllers());


app.UseStaticFiles();

app.UseCors(CorsPolicyName);

Expand Down
45 changes: 30 additions & 15 deletions Src/DeUrgenta.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DbConnectionString": "Server=localhost;Port=5432;Database=de-urgenta-db;User Id=docker;Password=docker;",
"IdentityDbConnectionString": "Server=localhost;Port=5432;Database=de-urgenta-db;User Id=docker;Password=docker;"
},
"JwtConfig": {
"Secret": "llvudfvkwvepwkdnsnwmuulyvtrawppf",
"TokenExpirationInSeconds": 3600
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DbConnectionString": "Server=localhost;Port=5432;Database=de-urgenta-db;User Id=docker;Password=docker;",
"IdentityDbConnectionString": "Server=localhost;Port=5432;Database=de-urgenta-db;User Id=docker;Password=docker;"
},
"JwtConfig": {
"Secret": "llvudfvkwvepwkdnsnwmuulyvtrawppf",
"TokenExpirationInSeconds": 3600
},
"EMailingSystem": "SendGrid",
"AdminFromName": "Echipa 'de urgenta'",
"AdminFromEmail": "admin@deurgenta.ro",
"ConfirmationUrl": "https://api.deurgenta.hostmysite.ro/confirmEmail.html",
"Smtp": {
"Host": "",
"Port": 0,
"User": "",
"Password": ""
},
"SendGrid": {
"ApiKey": "",
"ClickTracking": false
},
"TemplateFolder": "EmailTemplates"
}
33 changes: 33 additions & 0 deletions Src/DeUrgenta.Api/wwwroot/confirmEmail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Confirmare adresa de email</title>
</head>
<body>
<script>
function callback(xhr) {
if (xhr.status === 200) {
document.getElementById('status').innerHTML = 'Adresa de mail a fost confirmata. Va puteti intoarce in aplicatie.';
} else {
document.getElementById('status').innerHTML = 'Eroare.';
}
}
const urlParams = new URLSearchParams(window.location.search);
const userId = urlParams.get('userId');
const code = urlParams.get('code');

var xhr = new XMLHttpRequest();
xhr.open("POST", "/auth/confirm");
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
callback(xhr);
}
}
xhr.send(JSON.stringify({ "userId": userId, "code": code }));

</script>
<div id="status"></div>
</body>
</html>
25 changes: 0 additions & 25 deletions Src/DeUrgenta.IdentityServer.sln

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit f0379d5

Please sign in to comment.