Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public class EnvironmentSettings : IValidatable
[Required]
public string ShiftyUrl { get; set; }

[Required]
public string AnalogAppUrl { get; set; }

public void Validate()
{
Validator.ValidateObject(this, new ValidationContext(this), true);
Expand Down
6 changes: 3 additions & 3 deletions coffeecard/CoffeeCard.Library/Services/v2/EmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public async Task SendMagicLink(User user, string magicLink, LoginType loginType
);
var message = new MimeMessage();
var builder = RetrieveTemplate("email_magic_link_login.html");
var baseUrl = loginType switch
var baseUri = loginType switch
{
LoginType.Shifty => _environmentSettings.ShiftyUrl,
LoginType.App => throw new NotImplementedException(),
LoginType.App => _environmentSettings.AnalogAppUrl,
_ => throw new NotImplementedException(),
};

var deeplink = loginType.GetDeepLink(baseUrl, magicLink);
var deeplink = loginType.GetDeepLink(baseUri, magicLink);

builder = BuildMagicLinkEmail(builder, user.Email, user.Name, deeplink);

Expand Down
11 changes: 8 additions & 3 deletions coffeecard/CoffeeCard.Models/Entities/LoginType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ public static class LoginTypeExtensions
/// Get the deep link for the correct application
/// </summary>
/// <param name="loginType">The application to log in to</param>
/// <param name="baseUrl">The base URL for the application</param>
/// <param name="redirectUri">The redirect URI for the application</param>
/// <param name="tokenHash">The generated token associated with a user</param>
/// <returns>string</returns>
/// <exception cref="ApiException">Unable to resolve application to log in to</exception>
public static string GetDeepLink(this LoginType loginType, string baseUrl, string tokenHash)
public static string GetDeepLink(
this LoginType loginType,
string redirectUri,
string tokenHash
)
{
return loginType switch
{
LoginType.Shifty => $"{baseUrl}auth?token={tokenHash}",
LoginType.Shifty => $"{redirectUri}auth?token={tokenHash}",
LoginType.App => $"{redirectUri}://login/auth/{tokenHash}",
_ => throw new ApiException(
"Deep link for the given application has not been implemented"
),
Expand Down
3 changes: 2 additions & 1 deletion coffeecard/CoffeeCard.WebApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"EnvironmentType": "LocalDevelopment",
"MinAppVersion": "2.0.0",
"DeploymentUrl": "https://localhost:8081/",
"ShiftyUrl": "https://localhost:8001/"
"ShiftyUrl": "https://localhost:8001/",
"AnalogAppUrl": "https://localhost:8001/"
},
"DatabaseSettings": {
"ConnectionString": "Server=localhost;Initial Catalog=master;User=sa;Password=Your_password123;TrustServerCertificate=True;",
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/dev.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"name": "EnvironmentSettings__ShiftyUrl",
"value": "https://shifty.dev.analogio.dk/"
},
{
"name": "EnvironmentSettings__AnalogAppUrl",
"value": "cafeanalog-dev://cafeanalog.dk/"
},
{
"name": "MailgunSettings__Domain",
"value": "mg.cafeanalog.dk"
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/prd.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"name": "EnvironmentSettings__ShiftyUrl",
"value": "https://shifty.prd.analogio.dk/"
},
{
"name": "EnvironmentSettings__AnalogAppUrl",
"value": "cafeanalog://cafeanalog.dk/"
},
{
"name": "MailgunSettings__Domain",
"value": "mg.cafeanalog.dk"
Expand Down
Loading