Moved GetEnvironmentVariable calls to Application_Start
This commit is contained in:
parent
77f45fabb1
commit
7ddda56987
@ -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);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public class AppSettings {
|
||||
string urls,
|
||||
int userId,
|
||||
bool userIsAdmin,
|
||||
string wasmClientUrl,
|
||||
string wsr_URL,
|
||||
string? workingDirectoryName) {
|
||||
AdminNotificationRecepient = adminNotificationRecepient;
|
||||
@ -88,6 +89,7 @@ public class AppSettings {
|
||||
UserId = userId;
|
||||
UserIsAdmin = userIsAdmin;
|
||||
WSR_URL = wsr_URL;
|
||||
WasmClientUrl = wasmClientUrl;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
@ -130,6 +132,7 @@ public class AppSettings {
|
||||
public string URLs { get; }
|
||||
public int UserId { get; }
|
||||
public bool UserIsAdmin { get; }
|
||||
public string WasmClientUrl { get; }
|
||||
public string WSR_URL { get; }
|
||||
public string? WorkingDirectoryName { get; }
|
||||
|
||||
@ -217,6 +220,8 @@ public class AppSettings {
|
||||
string? smtpServer = ConfigurationManager.AppSettings["SMTP Server"]?.ToString();
|
||||
string? urls = ConfigurationManager.AppSettings["URLs"]?.ToString();
|
||||
string? workingDirectoryName = ConfigurationManager.AppSettings["WorkingDirectoryName"]?.ToString();
|
||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
||||
"https://localhost:7255";
|
||||
result = new(adminNotificationRecepient: adminNotificationRecepient,
|
||||
apiBaseUrl: apiBaseUrl,
|
||||
attachmentFolder: attachmentFolder,
|
||||
@ -256,6 +261,7 @@ public class AppSettings {
|
||||
urls: urls,
|
||||
userId: userId,
|
||||
userIsAdmin: Misc.GlobalVars.USER_ISADMIN,
|
||||
wasmClientUrl: wasmClientUrl,
|
||||
wsr_URL: Misc.GlobalVars.WSR_URL,
|
||||
workingDirectoryName: workingDirectoryName);
|
||||
return result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user