This commit is contained in:
mmrbnjd
2025-07-11 20:37:28 +03:30
parent 1924c88e7a
commit ff342a53c0
156 changed files with 13746 additions and 35 deletions

View File

@@ -52,7 +52,8 @@ namespace Hushian.Application.Services
if (auth.Username.StartsWith("09"))
{
// in Company Search
var Company = await _CompanyRepository.Get().FirstOrDefaultAsync(f => f.Mobile == auth.Username && f.Password == auth.Password.GetHash());
var Company = await _CompanyRepository.Get()
.FirstOrDefaultAsync(f => f.Mobile == auth.Username && f.Password == auth.Password.GetHash() && f.Verified);
if (Company == null)
{
Response.Errors.Add("کاربری یافت نشد");
@@ -64,14 +65,17 @@ namespace Hushian.Application.Services
{
Fullname = Company.FullName,
Id = Company.ID,
Role="Company",
img=Company.logo,
MobileOrUserName = Company.Mobile,
Token = new JwtSecurityTokenHandler().WriteToken(await GenerateToken(Company.Mobile, Company.ID))
Token = new JwtSecurityTokenHandler().WriteToken(await GenerateToken(Company.Mobile, Company.ID, "Company"))
};
}
}
else
{
var exper = await _ExperRepository.Get().FirstOrDefaultAsync(f => f.UserName == auth.Username && f.Password == auth.Password.GetHash());
var exper = await _ExperRepository.Get().FirstOrDefaultAsync(f => f.UserName == auth.Username
&& f.Password == auth.Password.GetHash() && f.Available);
if (exper == null)
{
Response.Errors.Add("کاربری یافت نشد");
@@ -83,8 +87,10 @@ namespace Hushian.Application.Services
{
Fullname = exper.FullName,
Id = exper.ID,
CompanyId = exper.CompanyID,
MobileOrUserName = exper.UserName,
Token = new JwtSecurityTokenHandler().WriteToken(await GenerateToken(exper.UserName, exper.ID))
Role="Exper",
Token = new JwtSecurityTokenHandler().WriteToken(await GenerateToken(exper.UserName, exper.ID, "Exper"))
};
}
}
@@ -121,12 +127,14 @@ namespace Hushian.Application.Services
return Response;
}
public async Task<JwtSecurityToken> GenerateToken(string UserName, int userId)
public async Task<JwtSecurityToken> GenerateToken(string UserName, int userId, string Role)
{
var claims = new[]
{
new Claim(JwtRegisteredClaimNames.Sub,UserName),
new Claim(CustomClaimTypes.Uid,userId.ToString())
new Claim(ClaimTypes.NameIdentifier, UserName),
new Claim(CustomClaimTypes.Uid,userId.ToString()),
new Claim(ClaimTypes.Role, Role)
};