Merge branch 'Feature/authorize/program-manager'

# Conflicts:
#	ServiceHost/appsettings.Development.json
#	ServiceHost/appsettings.json
This commit is contained in:
2025-12-07 18:25:18 +03:30
5 changed files with 82 additions and 9 deletions

View File

@@ -515,9 +515,16 @@
اطلاعات بانکی طرف حساب
</a></li>
</ul>
</li>
<li>
<a asp-area="AdminNew" asp-page="/Index" asp-page-handler="ProgramManager" class="waves-effect btnCustom">
<div class="menuTitle">
<i class="md md-home"></i>
<span> پروگرام منیجر </span>
</div>
</a>
</li>
</ul>
<div class="clearfix"></div>

View File

@@ -7,6 +7,10 @@ using Company.Domain.WorkshopAccountAgg;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.IdentityModel.Tokens;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
using WorkFlow.Application.Contracts.AdminWorkFlow;
namespace ServiceHost.Areas.AdminNew.Pages
@@ -121,5 +125,51 @@ namespace ServiceHost.Areas.AdminNew.Pages
data = checkerCount,
});
}
public IActionResult OnGetProgramManager()
{
try
{
// دریافت اطلاعات کاربر فعلی
var currentAccountId = _authHelper.CurrentAccountId();
var accountInfo = _authHelper.CurrentAccountInfo();
// تعریف Secret Key برای JWT (باید در appsettings.json تعریف شود)
var secretKey = _configuration["JwtSettings:SecretKey"] ?? ">3£>^1UBG@yw)QdhRC3$£:;r8~?qpp^oKK4D3a~8L2>enF;lkgh";
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey));
var credentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
// ایجاد Claims
var claims = new[]
{
new Claim(ClaimTypes.NameIdentifier, currentAccountId.ToString()),
new Claim(ClaimTypes.Name, accountInfo.Fullname ?? ""),
new Claim(ClaimTypes.Email, accountInfo.Username ?? ""),
new Claim("AccountId", currentAccountId.ToString()),
new Claim("RoleId", accountInfo.RoleId.ToString())
};
// ایجاد JWT Token
var token = new JwtSecurityToken(
issuer: _configuration["JwtSettings:Issuer"] ?? "GozareshgirApp",
audience: _configuration["JwtSettings:Audience"] ?? "GozareshgirUsers",
claims: claims,
expires: DateTime.UtcNow.AddMinutes(int.Parse(_configuration["JwtSettings:ExpirationMinutes"] ?? "30")),
signingCredentials: credentials
);
var tokenString = new JwtSecurityTokenHandler().WriteToken(token);
var domain = _configuration["GozareshgirProgramManager:Domain"] ?? "http://localhost:5000";
// Redirect به SSO-Login با Token
var ssoUrl = $"https://pm{domain}/ssologin?token={Uri.EscapeDataString(tokenString)}";
// var ssoUrl = $"https://localhost:7032/api/Auth/sso-login?token={Uri.EscapeDataString(tokenString)}";
return Redirect(ssoUrl);
}
catch (Exception ex)
{
// در صورت خطا، برگشت به صفحه اصلی
return RedirectToPage("/Index");
}
}
}
}

View File

@@ -663,8 +663,14 @@
اطلاعات بانکی طرف حساب
</a></li>
</ul>
</li>
<li>
<a asp-area="AdminNew" asp-page="/Index" asp-page-handler="ProgramManager" class="waves-effect btnCustom">
<div class="menuTitle">
<i class="md md-home"></i>
<span> پروگرام منیجر </span>
</div>
</a>
</li>
</ul>
<div class="clearfix"></div>

View File

@@ -56,7 +56,13 @@
"Dadmehrg": "https://api.pm.dadmehrg.ir",
"Gozareshgir": "https://api.pm.gozareshgir.ir"
},
"SepehrGateWayTerminalId": 99213700
"SepehrGateWayTerminalId": 99213700,
"JwtSettings": {
"SecretKey": ">3£>^1UBG@yw)QdhRC3$£:;r8~?qpp^oKK4D3a~8L2>enF;lkgh",
"Issuer": "GozareshgirApp",
"Audience": "GozareshgirUsers",
"ExpirationMinutes": 30
}
}

View File

@@ -7,7 +7,7 @@
}
},
"ConnectionStrings": {
//"MesbahDb": "Data Source=.\\MSSQLSERVER2019;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=mesbah_db;Password=sa142857$@;"
//"MesbahDb": "Data Source=.\\MSSQLSERVER2019;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=mesbah_db;Password=sa142857$@;"
"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;",
//dad-mehr
@@ -44,7 +44,11 @@
"Gozareshgir": "https://api.pm.gozareshgir.ir"
},
"SepehrGateWayTerminalId": 99213700
"SepehrGateWayTerminalId": 99213700,
"JwtSettings": {
"SecretKey": ">3£>^1UBG@yw)QdhRC3$£:;r8~?qpp^oKK4D3a~8L2>enF;lkgh",
"Issuer": "GozareshgirApp",
"Audience": "GozareshgirUsers",
"ExpirationMinutes": 30
}
}