Moved GetEnvironmentVariable calls to Application_Start
This commit is contained in:
parent
77f45fabb1
commit
7ddda56987
@ -24,12 +24,9 @@ namespace Fab2ApprovalSystem.Controllers;
|
|||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class AccountController : Controller {
|
public class AccountController : Controller {
|
||||||
private string _apiBaseUrl;
|
|
||||||
|
|
||||||
public AccountController()
|
public AccountController()
|
||||||
: this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()))) {
|
: 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) {
|
public AccountController(UserManager<ApplicationUser> userManager) {
|
||||||
@ -69,7 +66,7 @@ public class AccountController : Controller {
|
|||||||
bool isLoginValid;
|
bool isLoginValid;
|
||||||
|
|
||||||
HttpClient httpClient = HttpClientFactory.Create();
|
HttpClient httpClient = HttpClientFactory.Create();
|
||||||
httpClient.BaseAddress = new Uri(_apiBaseUrl);
|
httpClient.BaseAddress = new Uri(GlobalVars.AppSettings.ApiBaseUrl);
|
||||||
|
|
||||||
LoginResult loginResult = await AccountDMO.LoginAsync(httpClient, model);
|
LoginResult loginResult = await AccountDMO.LoginAsync(httpClient, model);
|
||||||
|
|
||||||
@ -121,7 +118,7 @@ public class AccountController : Controller {
|
|||||||
bool isLoginValid;
|
bool isLoginValid;
|
||||||
|
|
||||||
HttpClient httpClient = HttpClientFactory.Create();
|
HttpClient httpClient = HttpClientFactory.Create();
|
||||||
httpClient.BaseAddress = new Uri(_apiBaseUrl);
|
httpClient.BaseAddress = new Uri(GlobalVars.AppSettings.ApiBaseUrl);
|
||||||
|
|
||||||
LoginResult loginResult = await AccountDMO.ExternalAuthSetupAsync(httpClient, authAttempt);
|
LoginResult loginResult = await AccountDMO.ExternalAuthSetupAsync(httpClient, authAttempt);
|
||||||
|
|
||||||
|
@ -52,9 +52,7 @@ public class ChangeControlController : Controller {
|
|||||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||||
string refreshToken = Session["RefreshToken"].ToString();
|
string refreshToken = Session["RefreshToken"].ToString();
|
||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
||||||
"https://localhost:7255";
|
|
||||||
string mrbUrl = $"{wasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
|
||||||
|
|
||||||
return Redirect(mrbUrl);
|
return Redirect(mrbUrl);
|
||||||
}
|
}
|
||||||
@ -64,9 +62,7 @@ public class ChangeControlController : Controller {
|
|||||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||||
string refreshToken = Session["RefreshToken"].ToString();
|
string refreshToken = Session["RefreshToken"].ToString();
|
||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
||||||
"https://localhost:7255";
|
|
||||||
string mrbUrl = $"{wasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
|
||||||
|
|
||||||
return Redirect(mrbUrl);
|
return Redirect(mrbUrl);
|
||||||
}
|
}
|
||||||
|
@ -79,9 +79,7 @@ public class MRBController : Controller {
|
|||||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||||
string refreshToken = Session["RefreshToken"].ToString();
|
string refreshToken = Session["RefreshToken"].ToString();
|
||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/mrb/{issueID}";
|
||||||
"https://localhost:7255";
|
|
||||||
string mrbUrl = $"{wasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/mrb/{issueID}";
|
|
||||||
|
|
||||||
return Redirect(mrbUrl);
|
return Redirect(mrbUrl);
|
||||||
}
|
}
|
||||||
@ -104,9 +102,7 @@ public class MRBController : Controller {
|
|||||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||||
string refreshToken = Session["RefreshToken"].ToString();
|
string refreshToken = Session["RefreshToken"].ToString();
|
||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/mrb/{issueID}";
|
||||||
"https://localhost:7255";
|
|
||||||
string mrbUrl = $"{wasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/mrb/{issueID}";
|
|
||||||
|
|
||||||
return Redirect(mrbUrl);
|
return Redirect(mrbUrl);
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,7 @@ public class PCRBController : Controller {
|
|||||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||||
string refreshToken = Session["RefreshToken"].ToString();
|
string refreshToken = Session["RefreshToken"].ToString();
|
||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
||||||
"https://localhost:7255";
|
|
||||||
string mrbUrl = $"{wasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
|
||||||
|
|
||||||
return Redirect(mrbUrl);
|
return Redirect(mrbUrl);
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ public class AppSettings {
|
|||||||
string urls,
|
string urls,
|
||||||
int userId,
|
int userId,
|
||||||
bool userIsAdmin,
|
bool userIsAdmin,
|
||||||
|
string wasmClientUrl,
|
||||||
string wsr_URL,
|
string wsr_URL,
|
||||||
string? workingDirectoryName) {
|
string? workingDirectoryName) {
|
||||||
AdminNotificationRecepient = adminNotificationRecepient;
|
AdminNotificationRecepient = adminNotificationRecepient;
|
||||||
@ -88,6 +89,7 @@ public class AppSettings {
|
|||||||
UserId = userId;
|
UserId = userId;
|
||||||
UserIsAdmin = userIsAdmin;
|
UserIsAdmin = userIsAdmin;
|
||||||
WSR_URL = wsr_URL;
|
WSR_URL = wsr_URL;
|
||||||
|
WasmClientUrl = wasmClientUrl;
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
WorkingDirectoryName = workingDirectoryName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +132,7 @@ public class AppSettings {
|
|||||||
public string URLs { get; }
|
public string URLs { get; }
|
||||||
public int UserId { get; }
|
public int UserId { get; }
|
||||||
public bool UserIsAdmin { get; }
|
public bool UserIsAdmin { get; }
|
||||||
|
public string WasmClientUrl { get; }
|
||||||
public string WSR_URL { get; }
|
public string WSR_URL { get; }
|
||||||
public string? WorkingDirectoryName { get; }
|
public string? WorkingDirectoryName { get; }
|
||||||
|
|
||||||
@ -217,6 +220,8 @@ public class AppSettings {
|
|||||||
string? smtpServer = ConfigurationManager.AppSettings["SMTP Server"]?.ToString();
|
string? smtpServer = ConfigurationManager.AppSettings["SMTP Server"]?.ToString();
|
||||||
string? urls = ConfigurationManager.AppSettings["URLs"]?.ToString();
|
string? urls = ConfigurationManager.AppSettings["URLs"]?.ToString();
|
||||||
string? workingDirectoryName = ConfigurationManager.AppSettings["WorkingDirectoryName"]?.ToString();
|
string? workingDirectoryName = ConfigurationManager.AppSettings["WorkingDirectoryName"]?.ToString();
|
||||||
|
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
||||||
|
"https://localhost:7255";
|
||||||
result = new(adminNotificationRecepient: adminNotificationRecepient,
|
result = new(adminNotificationRecepient: adminNotificationRecepient,
|
||||||
apiBaseUrl: apiBaseUrl,
|
apiBaseUrl: apiBaseUrl,
|
||||||
attachmentFolder: attachmentFolder,
|
attachmentFolder: attachmentFolder,
|
||||||
@ -256,6 +261,7 @@ public class AppSettings {
|
|||||||
urls: urls,
|
urls: urls,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
userIsAdmin: Misc.GlobalVars.USER_ISADMIN,
|
userIsAdmin: Misc.GlobalVars.USER_ISADMIN,
|
||||||
|
wasmClientUrl: wasmClientUrl,
|
||||||
wsr_URL: Misc.GlobalVars.WSR_URL,
|
wsr_URL: Misc.GlobalVars.WSR_URL,
|
||||||
workingDirectoryName: workingDirectoryName);
|
workingDirectoryName: workingDirectoryName);
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user