Moved GetEnvironmentVariable calls to Application_Start
This commit is contained in:
@ -24,12 +24,9 @@ namespace Fab2ApprovalSystem.Controllers;
|
||||
|
||||
[Authorize]
|
||||
public class AccountController : Controller {
|
||||
private string _apiBaseUrl;
|
||||
|
||||
public AccountController()
|
||||
: this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()))) {
|
||||
_apiBaseUrl = Environment.GetEnvironmentVariable("FabApprovalApiBaseUrl") ??
|
||||
throw new ArgumentNullException("FabApprovalApiBaseUrl environment variable not found");
|
||||
}
|
||||
|
||||
public AccountController(UserManager<ApplicationUser> userManager) {
|
||||
@ -69,7 +66,7 @@ public class AccountController : Controller {
|
||||
bool isLoginValid;
|
||||
|
||||
HttpClient httpClient = HttpClientFactory.Create();
|
||||
httpClient.BaseAddress = new Uri(_apiBaseUrl);
|
||||
httpClient.BaseAddress = new Uri(GlobalVars.AppSettings.ApiBaseUrl);
|
||||
|
||||
LoginResult loginResult = await AccountDMO.LoginAsync(httpClient, model);
|
||||
|
||||
@ -121,7 +118,7 @@ public class AccountController : Controller {
|
||||
bool isLoginValid;
|
||||
|
||||
HttpClient httpClient = HttpClientFactory.Create();
|
||||
httpClient.BaseAddress = new Uri(_apiBaseUrl);
|
||||
httpClient.BaseAddress = new Uri(GlobalVars.AppSettings.ApiBaseUrl);
|
||||
|
||||
LoginResult loginResult = await AccountDMO.ExternalAuthSetupAsync(httpClient, authAttempt);
|
||||
|
||||
|
@ -52,9 +52,7 @@ public class ChangeControlController : Controller {
|
||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||
string refreshToken = Session["RefreshToken"].ToString();
|
||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
||||
"https://localhost:7255";
|
||||
string mrbUrl = $"{wasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
||||
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
||||
|
||||
return Redirect(mrbUrl);
|
||||
}
|
||||
@ -64,9 +62,7 @@ public class ChangeControlController : Controller {
|
||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||
string refreshToken = Session["RefreshToken"].ToString();
|
||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
||||
"https://localhost:7255";
|
||||
string mrbUrl = $"{wasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
||||
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
||||
|
||||
return Redirect(mrbUrl);
|
||||
}
|
||||
|
@ -79,9 +79,7 @@ public class MRBController : Controller {
|
||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||
string refreshToken = Session["RefreshToken"].ToString();
|
||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
||||
"https://localhost:7255";
|
||||
string mrbUrl = $"{wasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/mrb/{issueID}";
|
||||
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/mrb/{issueID}";
|
||||
|
||||
return Redirect(mrbUrl);
|
||||
}
|
||||
@ -104,9 +102,7 @@ public class MRBController : Controller {
|
||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||
string refreshToken = Session["RefreshToken"].ToString();
|
||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
||||
"https://localhost:7255";
|
||||
string mrbUrl = $"{wasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/mrb/{issueID}";
|
||||
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/mrb/{issueID}";
|
||||
|
||||
return Redirect(mrbUrl);
|
||||
}
|
||||
|
@ -13,9 +13,7 @@ public class PCRBController : Controller {
|
||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||
string refreshToken = Session["RefreshToken"].ToString();
|
||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
||||
"https://localhost:7255";
|
||||
string mrbUrl = $"{wasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
||||
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
||||
|
||||
return Redirect(mrbUrl);
|
||||
}
|
||||
|
Reference in New Issue
Block a user