refactor: add .editorconfig and refactor code
This commit is contained in:
		@@ -23,7 +23,8 @@ using OAuthProvider = Mirea.Api.Security.Common.Domain.OAuthProvider;
 | 
			
		||||
namespace Mirea.Api.Endpoint.Controllers.V1;
 | 
			
		||||
 | 
			
		||||
[ApiVersion("1.0")]
 | 
			
		||||
public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<GeneralConfig> generalConfig, AuthService auth, PasswordHashService passwordService, OAuthService oAuthService) : BaseController
 | 
			
		||||
public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<GeneralConfig> generalConfig, AuthService auth,
 | 
			
		||||
    PasswordHashService passwordService, OAuthService oAuthService) : BaseController
 | 
			
		||||
{
 | 
			
		||||
    private CookieOptionsParameters GetCookieParams() =>
 | 
			
		||||
        new()
 | 
			
		||||
@@ -34,8 +35,8 @@ public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<Gener
 | 
			
		||||
 | 
			
		||||
    private static string GenerateHtmlResponse(string title, string message, OAuthProvider? provider, bool isError = false, string? traceId = null)
 | 
			
		||||
    {
 | 
			
		||||
        string messageColor = isError ? "red" : "white";
 | 
			
		||||
        string script = "<script>setTimeout(()=>{if(window.opener){window.opener.postMessage(" +
 | 
			
		||||
        var messageColor = isError ? "red" : "white";
 | 
			
		||||
        var script = "<script>setTimeout(()=>{if(window.opener){window.opener.postMessage(" +
 | 
			
		||||
                        "{success:" + (!isError).ToString().ToLower() +
 | 
			
		||||
                        ",provider:'" + (provider == null ? "null" : (int)provider) +
 | 
			
		||||
                        "',providerName:'" + (provider == null ? "null" : Enum.GetName(provider.Value)) +
 | 
			
		||||
@@ -80,7 +81,8 @@ public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<Gener
 | 
			
		||||
            if (!userEntity.OAuthProviders.TryAdd(provider, oAuthUser))
 | 
			
		||||
            {
 | 
			
		||||
                title = "Ошибка связи аккаунта!";
 | 
			
		||||
                message = "Этот OAuth провайдер уже связан с вашей учетной записью. Пожалуйста, используйте другого провайдера или удалите связь с аккаунтом.";
 | 
			
		||||
                message = "Этот OAuth провайдер уже связан с вашей учетной записью. " +
 | 
			
		||||
                          "Пожалуйста, используйте другого провайдера или удалите связь с аккаунтом.";
 | 
			
		||||
                return Content(GenerateHtmlResponse(title, message, provider, true, traceId), "text/html");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@@ -138,7 +140,8 @@ public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<Gener
 | 
			
		||||
        if (!Enum.IsDefined(typeof(OAuthProvider), provider))
 | 
			
		||||
            throw new ControllerArgumentException("There is no selected provider");
 | 
			
		||||
 | 
			
		||||
        return Redirect(oAuthService.GetProviderRedirect(HttpContext, GetCookieParams(), HttpContext.GetApiUrl(Url.Action("OAuth2")!), (OAuthProvider)provider).AbsoluteUri);
 | 
			
		||||
        return Redirect(oAuthService.GetProviderRedirect(HttpContext, GetCookieParams(), HttpContext.GetApiUrl(Url.Action("OAuth2")!),
 | 
			
		||||
            (OAuthProvider)provider).AbsoluteUri);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user