Skip to content

Commit 8a28a38

Browse files
committed
Added parameterized url-ing
1 parent cf93640 commit 8a28a38

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

grade-management-new/GradeManagement.Server/Controllers/GitHubAppController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ namespace GradeManagement.Server.Controllers;
1515
public class GitHubAppController(IHttpClientFactory httpClientFactory) : ControllerBase
1616
{
1717
[HttpGet]
18-
public async Task CreateGitHubApp([FromQuery] string code)
18+
public async Task<IActionResult> CreateGitHubApp([FromQuery] string code)
1919
{
20+
string appUrl = Environment.GetEnvironmentVariable("APP_URL");
2021
string keyVaultUrl = Environment.GetEnvironmentVariable("KEY_VAULT_URI");
2122
var client = new SecretClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
2223
var httpClient = httpClientFactory.CreateClient();
@@ -36,6 +37,8 @@ await client.SetSecretAsync($"GitHubMonitorConfig--{gitHubApp.Owner.Login}--GitH
3637
await client.SetSecretAsync($"GitHubMonitorConfig--{gitHubApp.Owner.Login}--GitHubAppPrivateKey", pem);
3738
await client.SetSecretAsync($"GitHubMonitorConfig--{gitHubApp.Owner.Login}--GitHubWebhookSecret",
3839
gitHubApp.WebhookSecret);
40+
41+
return Redirect(appUrl);
3942
}
4043

4144
public static string RemovePemFencing(string pem)

grade-management-new/GradeManagement.Shared/Dtos/GitHubManifest/GitHubAppManifest.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ namespace GradeManagement.Shared.Dtos.GitHubManifest;
44

55
public class GitHubAppManifest
66
{
7+
public GitHubAppManifest()
8+
{
9+
string appUrl = Environment.GetEnvironmentVariable("APP_URL");
10+
RedirectUrl = $"{appUrl}api/github";
11+
}
12+
713
[JsonPropertyName("name")]
814
public string Name { get; set; } = "Ahk GitHub Monitor";
915
[JsonPropertyName("url")]
1016
public string Url { get; set; } = "https://github.com/bmeaut/ahk-github-automation";
1117
[JsonPropertyName("hook_attributes")]
12-
public HookAttributes HookAttributes { get; set; } = new HookAttributes();
18+
public HookAttributes HookAttributes { get; set; }
1319
[JsonPropertyName("redirect_url")]
14-
public string RedirectUrl { get; set; } = "https://app.mm-home.eu/api/github";
20+
public string RedirectUrl { get; set; }
1521
[JsonPropertyName("callback_urls")]
1622
public List<string> CallbackUrls { get; set; } = new();
1723
/*[JsonPropertyName("setup_url")]

grade-management-new/GradeManagement.Shared/Dtos/GitHubManifest/HookAttributes.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ namespace GradeManagement.Shared.Dtos.GitHubManifest;
44

55
public class HookAttributes
66
{
7+
public HookAttributes()
8+
{
9+
string monitorUrl = Environment.GetEnvironmentVariable("MONITOR_URL");
10+
Url = $"{monitorUrl}api/github-webhooks";
11+
}
12+
713
[JsonPropertyName("url")]
8-
public string Url { get; set; } = "https://monitor.mm-home.eu/api/github-webhooks";
14+
public string Url { get; set; }
915
[JsonPropertyName("active")]
1016
public bool Active { get; set; } = true;
1117
}

0 commit comments

Comments
 (0)