...
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Service">
|
<Reference Include="Service">
|
||||||
<HintPath>..\..\Dlls\Service.dll</HintPath>
|
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@@ -60,7 +60,7 @@ namespace Back.Controllers
|
|||||||
[HttpPost("CreateCsrAndPrivateKey")]
|
[HttpPost("CreateCsrAndPrivateKey")]
|
||||||
public async Task<ActionResult<TaxToolsDTO>> CreateCsrAndPrivateKey(CsrPrivateKeyDto model)
|
public async Task<ActionResult<TaxToolsDTO>> CreateCsrAndPrivateKey(CsrPrivateKeyDto model)
|
||||||
{
|
{
|
||||||
var resultValidationmodel = await _mobilevalidation.ValidateAsync(Tuple.Create(model.Mobile,false));
|
var resultValidationmodel = await _mobilevalidation.ValidateAsync(Tuple.Create(model.Mobile, ActionMobileValidation.No));
|
||||||
if (!resultValidationmodel.IsValid)
|
if (!resultValidationmodel.IsValid)
|
||||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||||
return Ok(await _sBase.CreateCsrAndPrivateKey(model));
|
return Ok(await _sBase.CreateCsrAndPrivateKey(model));
|
||||||
@@ -164,7 +164,7 @@ namespace Back.Controllers
|
|||||||
// Type = "catch"
|
// Type = "catch"
|
||||||
//};
|
//};
|
||||||
//_contextMongodb.InsertItem(log);
|
//_contextMongodb.InsertItem(log);
|
||||||
return BadRequest("خطای سیستمی رخ داده");
|
return BadRequest(new List<string> { "خطای سیستمی رخ داده" });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ namespace Back.Controllers
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<ActionResult<string>> ForgetPassWord(ForgetPasswordItem Item)
|
public async Task<ActionResult<string>> ForgetPassWord(ForgetPasswordItem Item)
|
||||||
{
|
{
|
||||||
var resultValidationmodel = await _mobilevalidation.ValidateAsync(Tuple.Create(Item.Username, true));
|
var resultValidationmodel = await _mobilevalidation.ValidateAsync(Tuple.Create(Item.Username, ActionMobileValidation.ExistMobile));
|
||||||
if (!resultValidationmodel.IsValid)
|
if (!resultValidationmodel.IsValid)
|
||||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||||
|
|
||||||
|
@@ -12,18 +12,37 @@ namespace Back.Controllers
|
|||||||
public class CompanyController : ControllerBase
|
public class CompanyController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly servCompany _servCompany;
|
private readonly servCompany _servCompany;
|
||||||
public CompanyController(servCompany servCompany)
|
private readonly servUser _servUser;
|
||||||
|
public CompanyController(servCompany servCompany, servUser servUser)
|
||||||
{
|
{
|
||||||
|
_servUser = servUser;
|
||||||
_servCompany = servCompany;
|
_servCompany = servCompany;
|
||||||
}
|
}
|
||||||
[HttpPost("ChangeLogo")]
|
[HttpPost("ChangeLogo")]
|
||||||
public async Task<ActionResult<bool>> ChangeLogo(byte[] logo)
|
public async Task<ActionResult<bool>> ChangeLogo(byte[] logo)
|
||||||
{
|
{
|
||||||
//var result = await _sBase.ReadPublicKeyFromCER(modelfromBase64);
|
if (logo == null)
|
||||||
//if (result.type == "error")
|
return BadRequest();
|
||||||
// return BadRequest();
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||||
|
var UserID = claim.Value;
|
||||||
return Ok();
|
var result = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||||
|
var company = result?.RolUsers.First().Company;
|
||||||
|
company.Logo= logo;
|
||||||
|
return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company));
|
||||||
|
}
|
||||||
|
[HttpGet("ChangeName/{name}")]
|
||||||
|
public async Task<ActionResult<bool>> ChangeName(string name)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(name) || name.Length<=3)
|
||||||
|
return BadRequest(new List<string> { "نام صحیح نمی باشد"});
|
||||||
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||||
|
var UserID = claim.Value;
|
||||||
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||||
|
var company = user?.RolUsers.First().Company;
|
||||||
|
company.Name = name;
|
||||||
|
user.Fullname=name;
|
||||||
|
await _servUser.UpdateUser(user);
|
||||||
|
return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ namespace Back.Controllers
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<ActionResult<int>> NewTicketNoAuthentication(CTicketNoAuthenticationDto item)
|
public async Task<ActionResult<int>> NewTicketNoAuthentication(CTicketNoAuthenticationDto item)
|
||||||
{
|
{
|
||||||
var resultValidationmodel = await _mobilevalidation.ValidateAsync(Tuple.Create(item.Mobile,false));
|
var resultValidationmodel = await _mobilevalidation.ValidateAsync(Tuple.Create(item.Mobile,ActionMobileValidation.No));
|
||||||
if (!resultValidationmodel.IsValid)
|
if (!resultValidationmodel.IsValid)
|
||||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||||
|
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
using Back.Services;
|
using Back.Data.Models;
|
||||||
|
using Back.Services;
|
||||||
|
using Back.Validations;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -12,11 +14,19 @@ namespace Back.Controllers
|
|||||||
public class UserController : ControllerBase
|
public class UserController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly servUser _servUser;
|
private readonly servUser _servUser;
|
||||||
public UserController(servUser servUser)
|
private readonly servCompany _servCompany;
|
||||||
|
private readonly MobileValidation _mobilevalidation;
|
||||||
|
private readonly ServValidatinMsg _servValidatinMsg;
|
||||||
|
private readonly servSendMsg _servSendMsg;
|
||||||
|
public UserController(servUser servUser, MobileValidation mobilevalidation, servCompany servCompany
|
||||||
|
, ServValidatinMsg servValidatinMsg, servSendMsg servSendMsg)
|
||||||
{
|
{
|
||||||
|
|
||||||
_servUser = servUser;
|
_servUser = servUser;
|
||||||
|
_mobilevalidation = mobilevalidation;
|
||||||
|
_servCompany = servCompany;
|
||||||
|
_servValidatinMsg = servValidatinMsg;
|
||||||
|
_servSendMsg = servSendMsg;
|
||||||
}
|
}
|
||||||
[HttpPost("authenticate")]
|
[HttpPost("authenticate")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
@@ -50,7 +60,27 @@ namespace Back.Controllers
|
|||||||
return Ok(await _servUser.ChangePassword(item.newPass.Trim(), Convert.ToInt32(UserID)));
|
return Ok(await _servUser.ChangePassword(item.newPass.Trim(), Convert.ToInt32(UserID)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
[HttpGet("ChangeUserName/{newUsername}")]
|
||||||
|
public async Task<ActionResult<bool>> ChangeUserName(string newUsername)
|
||||||
|
{
|
||||||
|
var resultValidationmodel = await _mobilevalidation.ValidateAsync(Tuple.Create(newUsername, ActionMobileValidation.nonExistMobile));
|
||||||
|
if (!resultValidationmodel.IsValid)
|
||||||
|
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||||
|
|
||||||
|
var UserID = HttpContext.User.Claims.First(c => c.Type == "UserID").Value;
|
||||||
|
|
||||||
|
var ID = await _servValidatinMsg.GenerateCode(new VerificationCode
|
||||||
|
{
|
||||||
|
prm = UserID,
|
||||||
|
val = newUsername,
|
||||||
|
Type = "ChangeUserName"
|
||||||
|
});
|
||||||
|
|
||||||
|
_servSendMsg.Authentication(newUsername, ID.ToString());
|
||||||
|
return Ok(ID);
|
||||||
|
|
||||||
|
// return Ok(await _servUser.ChangeUserName(newUsername, Convert.ToInt32(UserID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -69,8 +69,14 @@ namespace Back.Controllers
|
|||||||
_servSendMsg.Authentication(_getVerificationValidation.verificationCode.prm, ID.ToString());
|
_servSendMsg.Authentication(_getVerificationValidation.verificationCode.prm, ID.ToString());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case "ChangeUserName":
|
||||||
|
_servSendMsg.Authentication(_getVerificationValidation.verificationCode.val, ID.ToString());
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return BadRequest("این نوع احراز تعریف نشده");
|
return BadRequest(new List<string> { "این نوع احراز تعریف نشده" });
|
||||||
}
|
}
|
||||||
|
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@@ -79,7 +85,7 @@ namespace Back.Controllers
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<ActionResult<bool>> Submit(VerificationCodeDto item)
|
public async Task<ActionResult<bool>> Submit(VerificationCodeDto item)
|
||||||
{
|
{
|
||||||
var VerificationCode= await _servValidatinMsg.GetVerificationCode(item.ID);
|
var VerificationCode= await _servValidatinMsg.GetVerificationCodeByID(item.ID);
|
||||||
if (VerificationCode==null)
|
if (VerificationCode==null)
|
||||||
return NotFound("آیتمی یافت نشد");
|
return NotFound("آیتمی یافت نشد");
|
||||||
|
|
||||||
@@ -101,8 +107,12 @@ namespace Back.Controllers
|
|||||||
//else return BadRequest();
|
//else return BadRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "ChangeUserName":
|
||||||
|
Sucstatus = await _servUser.ChangeUserName(VerificationCode.val, Convert.ToInt32(VerificationCode.prm));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return BadRequest("این نوع احراز تعریف نشده");
|
return BadRequest(new List<string> { "این نوع احراز تعریف نشده" });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Sucstatus)
|
if (Sucstatus)
|
||||||
@@ -110,17 +120,17 @@ namespace Back.Controllers
|
|||||||
|
|
||||||
return Ok(Sucstatus);
|
return Ok(Sucstatus);
|
||||||
}
|
}
|
||||||
else return BadRequest("اطلاعات شما منطبق با سامانه نیست");
|
else return BadRequest(new List<string> { "اطلاعات شما منطبق با سامانه نیست" });
|
||||||
|
|
||||||
}
|
}
|
||||||
else return BadRequest("کد احراز صحیح نمی باشد");
|
else return BadRequest(new List<string> { "کد احراز صحیح نمی باشد" });
|
||||||
|
|
||||||
}
|
}
|
||||||
[HttpDelete("Remove/{ID}")]
|
[HttpDelete("Remove/{ID}")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<ActionResult<bool>> Remove(int ID)
|
public async Task<ActionResult<bool>> Remove(int ID)
|
||||||
{
|
{
|
||||||
var VerificationCode = await _servValidatinMsg.GetVerificationCode(ID);
|
var VerificationCode = await _servValidatinMsg.GetVerificationCodeByID(ID);
|
||||||
await _servValidatinMsg.Delete(VerificationCode);
|
await _servValidatinMsg.Delete(VerificationCode);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@ namespace Back.Data.Infrastructure.Repository
|
|||||||
{
|
{
|
||||||
public class RepositoryBase<T> : IAsyncRepository<T> where T : class
|
public class RepositoryBase<T> : IAsyncRepository<T> where T : class
|
||||||
{
|
{
|
||||||
protected readonly SqlDbContext _dbContext;
|
public readonly SqlDbContext _dbContext;
|
||||||
private DbSet<T> _query;
|
private DbSet<T> _query;
|
||||||
public RepositoryBase(SqlDbContext dbContext)
|
public RepositoryBase(SqlDbContext dbContext)
|
||||||
{
|
{
|
||||||
|
@@ -22,6 +22,7 @@ builder.Services.AddDbContext<SqlDbContext>(options =>
|
|||||||
options.UseSqlServer(builder.Configuration.GetConnectionString("Base"));
|
options.UseSqlServer(builder.Configuration.GetConnectionString("Base"));
|
||||||
});
|
});
|
||||||
builder.Services.AddScoped(typeof(IAsyncRepository<>), typeof(RepositoryBase<>));
|
builder.Services.AddScoped(typeof(IAsyncRepository<>), typeof(RepositoryBase<>));
|
||||||
|
builder.Services.AddScoped(typeof(RepositoryBase<>), typeof(RepositoryBase<>));
|
||||||
builder.Services.AddScoped<Back.Services.ServBase>();
|
builder.Services.AddScoped<Back.Services.ServBase>();
|
||||||
builder.Services.AddScoped<MobileValidation> ();
|
builder.Services.AddScoped<MobileValidation> ();
|
||||||
builder.Services.AddScoped<Service.Main>();
|
builder.Services.AddScoped<Service.Main>();
|
||||||
|
@@ -28,6 +28,10 @@ namespace Back.Services
|
|||||||
|
|
||||||
}
|
}
|
||||||
public async Task<VerificationCode> GetVerificationCode(int ID)
|
public async Task<VerificationCode> GetVerificationCode(int ID)
|
||||||
|
{
|
||||||
|
return await _verificationCodeRepo.Get(w => w.Code == ID).FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
public async Task<VerificationCode> GetVerificationCodeByID(int ID)
|
||||||
{
|
{
|
||||||
return await _verificationCodeRepo.Get(w => w.ID == ID).FirstOrDefaultAsync();
|
return await _verificationCodeRepo.Get(w => w.ID == ID).FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
@@ -68,7 +72,7 @@ namespace Back.Services
|
|||||||
public async Task<int> GenerateCode(VerificationCode code)
|
public async Task<int> GenerateCode(VerificationCode code)
|
||||||
{
|
{
|
||||||
code.Code = Random.Shared.Next(1000, 9000);
|
code.Code = Random.Shared.Next(1000, 9000);
|
||||||
while (await GetVerificationCode(code.ID) != null)
|
while (await GetVerificationCode(code.Code) != null)
|
||||||
code.Code = Random.Shared.Next(1000, 9000);
|
code.Code = Random.Shared.Next(1000, 9000);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -100,9 +100,57 @@ namespace Back.Services
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<bool> ExistMobileAndCompanyIsActive(string mobile)
|
public async Task<bool> AddORUpdateCompanyBoolResult(Company item)
|
||||||
{
|
{
|
||||||
return await _repoCompany.GetAll().AnyAsync(w => w.Mobile == mobile && w.IsActive);
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//SysLog log = new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddORUpdateCompany",
|
||||||
|
// Value = "*" + JsonConvert.SerializeObject(item),
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "User"
|
||||||
|
//};
|
||||||
|
//_contextMongodb.InsertItem(log);
|
||||||
|
|
||||||
|
if (item.ID == null || item.ID == 0)
|
||||||
|
{
|
||||||
|
return await _repoCompany.AddBoolResultAsync(item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return await _repoCompany.UpdateAsync(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//SysLog log = new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddORUpdateCompany",
|
||||||
|
// Value = ex.Message,
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "catch"
|
||||||
|
//};
|
||||||
|
//_contextMongodb.InsertItem(log);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task<bool> ExistMobileInCompany(string mobile,bool IsActive=true)
|
||||||
|
{
|
||||||
|
var resquest= _repoCompany.GetAll().Where(w => w.Mobile == mobile );
|
||||||
|
if (IsActive)
|
||||||
|
resquest = resquest.Where(w => w.IsActive);
|
||||||
|
|
||||||
|
return await resquest.AnyAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using Back.Common;
|
using Back.Common;
|
||||||
using Back.Data.Contracts;
|
using Back.Data.Contracts;
|
||||||
|
using Back.Data.Infrastructure.Repository;
|
||||||
using Back.Data.Models;
|
using Back.Data.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
@@ -17,16 +18,19 @@ namespace Back.Services
|
|||||||
|
|
||||||
private readonly servNotification _servNotification;
|
private readonly servNotification _servNotification;
|
||||||
private readonly IAsyncRepository<User> _RepoUser;
|
private readonly IAsyncRepository<User> _RepoUser;
|
||||||
|
private readonly RepositoryBase<Company> _RepoCompany;
|
||||||
private readonly IAsyncRepository<PermissionPeriod> _RepoPermissionPeriod;
|
private readonly IAsyncRepository<PermissionPeriod> _RepoPermissionPeriod;
|
||||||
public servUser(IConfiguration configuration
|
public servUser(IConfiguration configuration
|
||||||
, servNotification servNotification
|
, servNotification servNotification
|
||||||
, IAsyncRepository<User> RepoUser
|
, IAsyncRepository<User> RepoUser
|
||||||
, IAsyncRepository<PermissionPeriod> RepoPermissionPeriod)
|
, IAsyncRepository<PermissionPeriod> RepoPermissionPeriod
|
||||||
|
, RepositoryBase<Company> repoCompany)
|
||||||
{
|
{
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_servNotification = servNotification;
|
_servNotification = servNotification;
|
||||||
_RepoUser = RepoUser;
|
_RepoUser = RepoUser;
|
||||||
_RepoPermissionPeriod = RepoPermissionPeriod;
|
_RepoPermissionPeriod = RepoPermissionPeriod;
|
||||||
|
_RepoCompany = repoCompany;
|
||||||
}
|
}
|
||||||
public async Task<User?> GetUserByUserNameAndPassword(string UserName, string Password)
|
public async Task<User?> GetUserByUserNameAndPassword(string UserName, string Password)
|
||||||
{
|
{
|
||||||
@@ -252,12 +256,56 @@ namespace Back.Services
|
|||||||
return false;
|
return false;
|
||||||
user.Password = newPass.encrypted();
|
user.Password = newPass.encrypted();
|
||||||
return await _RepoUser.UpdateAsync(user);
|
return await _RepoUser.UpdateAsync(user);
|
||||||
|
}
|
||||||
|
public async Task<bool> ChangeUserName(string newUserName, int UserID)
|
||||||
|
{
|
||||||
|
var user = await GetUserByUserID(UserID);
|
||||||
|
if (user == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
using var transaction = _RepoCompany._dbContext.Database.BeginTransaction();
|
||||||
|
var company = user.RolUsers.First().Company;
|
||||||
|
company.Mobile = newUserName;
|
||||||
|
if (await _RepoCompany.UpdateAsync(company))
|
||||||
|
{
|
||||||
|
user.Username = newUserName;
|
||||||
|
user.Mobile = newUserName;
|
||||||
|
if (await _RepoUser.UpdateAsync(user))
|
||||||
|
{
|
||||||
|
transaction.Commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public async Task<bool> PermissionChangePassword(string oldPass, int UserID)
|
public async Task<bool> PermissionChangePassword(string oldPass, int UserID)
|
||||||
{
|
{
|
||||||
return await _RepoUser.GetAll().AnyAsync(w => w.ID == UserID && w.Password == oldPass.encrypted() && w.IsActive);
|
return await _RepoUser.GetAll().AnyAsync(w => w.ID == UserID && w.Password == oldPass.encrypted() && w.IsActive);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public async Task<bool> ExistMobileInUser(string mobile, bool IsActive = true)
|
||||||
|
{
|
||||||
|
var resquest = _RepoUser.Get(w => w.Mobile == mobile || w.Username == mobile);
|
||||||
|
if (IsActive)
|
||||||
|
resquest = resquest.Where(w => w.IsActive);
|
||||||
|
|
||||||
|
return await resquest.AnyAsync();
|
||||||
|
}
|
||||||
//--------internal
|
//--------internal
|
||||||
private async Task<string> GetJwt_Lifetime_Minutes()
|
private async Task<string> GetJwt_Lifetime_Minutes()
|
||||||
{
|
{
|
||||||
|
@@ -14,7 +14,7 @@ namespace Back.Validations
|
|||||||
.NotNull().WithMessage("موبایل نمی تواند باشد")
|
.NotNull().WithMessage("موبایل نمی تواند باشد")
|
||||||
.Length(11).WithMessage("فرمت موبایل صحیح نمی باشد")
|
.Length(11).WithMessage("فرمت موبایل صحیح نمی باشد")
|
||||||
.Must(m => m.StartsWith("09")).WithMessage("فرمت موبایل صحیح نمی باشد")
|
.Must(m => m.StartsWith("09")).WithMessage("فرمت موبایل صحیح نمی باشد")
|
||||||
.Must(mo=> !servCompany.ExistMobileAndCompanyIsActive(mo).Result)
|
.Must(mo=> !servCompany.ExistMobileInCompany(mo).Result)
|
||||||
.WithMessage("این موبایل قبلا ثبت شده");
|
.WithMessage("این موبایل قبلا ثبت شده");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ namespace Back.Validations
|
|||||||
CascadeMode = CascadeMode.Stop;
|
CascadeMode = CascadeMode.Stop;
|
||||||
RuleFor(model => model)
|
RuleFor(model => model)
|
||||||
.Custom((model, context) => {
|
.Custom((model, context) => {
|
||||||
verificationCode= _servValidatinMsg.GetVerificationCode(model).Result;
|
verificationCode= _servValidatinMsg.GetVerificationCodeByID(model).Result;
|
||||||
if (verificationCode==null)
|
if (verificationCode==null)
|
||||||
context.AddFailure("کد یافت نشد");
|
context.AddFailure("کد یافت نشد");
|
||||||
|
|
||||||
|
@@ -5,9 +5,16 @@ using System;
|
|||||||
|
|
||||||
namespace Back.Validations
|
namespace Back.Validations
|
||||||
{
|
{
|
||||||
public class MobileValidation : AbstractValidator<Tuple<string,bool>>
|
public enum ActionMobileValidation
|
||||||
{
|
{
|
||||||
public MobileValidation(servCompany servCompany)
|
No,
|
||||||
|
ExistMobile,
|
||||||
|
nonExistMobile,
|
||||||
|
|
||||||
|
}
|
||||||
|
public class MobileValidation : AbstractValidator<Tuple<string, ActionMobileValidation>>
|
||||||
|
{
|
||||||
|
public MobileValidation(servCompany servCompany,servUser servUser)
|
||||||
{
|
{
|
||||||
CascadeMode = CascadeMode.Stop;
|
CascadeMode = CascadeMode.Stop;
|
||||||
RuleFor(m => m.Item1)
|
RuleFor(m => m.Item1)
|
||||||
@@ -17,14 +24,24 @@ namespace Back.Validations
|
|||||||
.Must(m => m.StartsWith("09")).WithMessage("فرمت موبایل صحیح نمی باشد");
|
.Must(m => m.StartsWith("09")).WithMessage("فرمت موبایل صحیح نمی باشد");
|
||||||
RuleFor(m => m)
|
RuleFor(m => m)
|
||||||
.Custom((model, context) => {
|
.Custom((model, context) => {
|
||||||
if (model.Item2)
|
if (model.Item2== ActionMobileValidation.ExistMobile)
|
||||||
{
|
{
|
||||||
if (!servCompany.ExistMobileAndCompanyIsActive(model.Item1).Result)
|
if (!servCompany.ExistMobileInCompany(model.Item1).Result)
|
||||||
{
|
{
|
||||||
context.AddFailure("این موبایل یافت نشد");
|
context.AddFailure("این موبایل یافت نشد");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (model.Item2 == ActionMobileValidation.nonExistMobile)
|
||||||
|
{
|
||||||
|
if (servCompany.ExistMobileInCompany(model.Item1,false).Result)
|
||||||
|
context.AddFailure("این موبایل در سیستم تعریف شده");
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (servUser.ExistMobileInUser(model.Item1, false).Result)
|
||||||
|
context.AddFailure("این موبایل در سیستم تعریف شده");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
stroke-linejoin="round" />
|
stroke-linejoin="round" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<span>@userinfo.FullName</span>
|
<span>@userinfo.Company.Name</span>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
@inject UserAuthenticationDTO userinfo
|
@inject UserAuthenticationDTO userinfo
|
||||||
@inject HttpClient _hc
|
@inject HttpClient _hc
|
||||||
@inject NavigationManager nav
|
@inject NavigationManager nav
|
||||||
|
@inject localService localserv;
|
||||||
<HeadContent>
|
<HeadContent>
|
||||||
<link rel="canonical" href="#">
|
<link rel="canonical" href="#">
|
||||||
<!-- Favicon -->
|
<!-- Favicon -->
|
||||||
@@ -199,6 +200,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@functions {
|
@functions {
|
||||||
private async Task Logout()
|
private async Task Logout()
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
@page "/Profile"
|
@page "/Profile"
|
||||||
|
@page "/Profile/{from}"
|
||||||
@using Front.Services
|
@using Front.Services
|
||||||
@using Shared.DTOs
|
@using Shared.DTOs
|
||||||
@layout PanelLayout
|
@layout PanelLayout
|
||||||
@@ -53,19 +54,19 @@
|
|||||||
<div class="mb-3 row">
|
<div class="mb-3 row">
|
||||||
<label for="defaultFormControlInput" class="form-label">کلمه عبور فعلی</label>
|
<label for="defaultFormControlInput" class="form-label">کلمه عبور فعلی</label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<InputText @bind-Value="@changepassModel.oldPass" style="text-align:center;" class="form-control" type="password" id="html5-password-input"/>
|
<InputText @bind-Value="@changepassModel.oldPass" style="text-align:center;" class="form-control" type="password" id="html5-password-input1"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3 row">
|
<div class="mb-3 row">
|
||||||
<label for="defaultFormControlInput" class="form-label">کلمه عبور جدید</label>
|
<label for="defaultFormControlInput" class="form-label">کلمه عبور جدید</label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<InputText style="text-align:center;" @bind-Value="@changepassModel.newPass" class="form-control" type="password" id="html5-password-input" />
|
<InputText style="text-align:center;" @bind-Value="@changepassModel.newPass" class="form-control" type="password" id="html5-password-input2" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3 row">
|
<div class="mb-3 row">
|
||||||
<label for="defaultFormControlInput" class="form-label">تکرار کلمه عبور جدید</label>
|
<label for="defaultFormControlInput" class="form-label">تکرار کلمه عبور جدید</label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<InputText @bind-Value="@changepassModel.renewPass" style="text-align:center;" class="form-control" type="password" id="html5-password-input" />
|
<InputText @bind-Value="@changepassModel.renewPass" style="text-align:center;" class="form-control" type="password" id="html5-password-input3" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">ارسال</button>
|
<button type="submit" class="btn btn-primary">ارسال</button>
|
||||||
@@ -78,16 +79,16 @@
|
|||||||
<div class="card mb-4">
|
<div class="card mb-4">
|
||||||
<h5 class="card-header">تغییر نام کاربری/ موبایل</h5>
|
<h5 class="card-header">تغییر نام کاربری/ موبایل</h5>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form>
|
<EditForm Model="newUsername" OnSubmit="changeUserNameSubmit" FormName="changeUsername">
|
||||||
<div class="mb-3 row">
|
<div class="mb-3 row">
|
||||||
<label for="defaultFormControlInput" class="form-label">موبایل جدید</label>
|
<label for="defaultFormControlInput" class="form-label">موبایل جدید</label>
|
||||||
<div class="input-group input-group-merge">
|
<div class="input-group input-group-merge">
|
||||||
<input type="text" style="text-align:left;" id="basic-icon-default-phone" class="form-control phone-mask" placeholder="0000 000 0911" aria-label="0000 000 0911" value="@userinfo.UserName" aria-describedby="basic-icon-default-phone2">
|
<InputText @bind-Value="@newUsername" type="text" style="text-align:left;" id="basic-icon-default-phone" class="form-control phone-mask" placeholder="0000 000 0911" aria-label="0000 000 0911" aria-describedby="basic-icon-default-phone2"/>
|
||||||
<span id="basic-icon-default-phone2" class="input-group-text"><i class="bx bx-phone"></i></span>
|
<span id="basic-icon-default-phone2" class="input-group-text"><i class="bx bx-phone"></i></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">ارسال</button>
|
<button type="submit" class="btn btn-primary">ارسال</button>
|
||||||
</form>
|
</EditForm>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -98,16 +99,16 @@
|
|||||||
<div class="card mb-4">
|
<div class="card mb-4">
|
||||||
<h5 class="card-header">تغییر نام</h5>
|
<h5 class="card-header">تغییر نام</h5>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form>
|
<EditForm Model="newname" OnSubmit="changeNameSubmit" FormName="changename">
|
||||||
<div class="mb-3 row">
|
<div class="mb-3 row">
|
||||||
<label for="defaultFormControlInput" class="form-label">نام جدید</label>
|
<label for="defaultFormControlInput" class="form-label">نام جدید</label>
|
||||||
<div class="input-group input-group-merge">
|
<div class="input-group input-group-merge">
|
||||||
<span id="basic-icon-default-company2" class="input-group-text"><i class="bx bx-buildings"></i></span>
|
<span id="basic-icon-default-company2" class="input-group-text"><i class="bx bx-buildings"></i></span>
|
||||||
<input style="text-align:right;" type="text" id="basic-icon-default-company" value="@userinfo.Company.Name" class="form-control" placeholder="@userinfo.Company.Name" aria-label="@userinfo.Company.Name" aria-describedby="basic-icon-default-company2">
|
<InputText @bind-Value="@newname" style="text-align:right;" type="text" id="basic-icon-default-company" class="form-control" placeholder="@userinfo.Company.Name" aria-label="@userinfo.Company.Name" aria-describedby="basic-icon-default-company2"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">ارسال</button>
|
<button type="submit" class="btn btn-primary">ارسال</button>
|
||||||
</form>
|
</EditForm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -118,17 +119,37 @@
|
|||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string from { get; set; } = "";
|
||||||
|
|
||||||
public string _src { get; set; }
|
public string _src { get; set; }
|
||||||
private long maxFileSize = 1024 * 15;
|
private long maxFileSize = 1024 * 15;
|
||||||
[SupplyParameterFromForm]
|
[SupplyParameterFromForm]
|
||||||
public ChangePasswordDto changepassModel { get; set; }
|
public ChangePasswordDto changepassModel { get; set; }
|
||||||
|
[SupplyParameterFromForm]
|
||||||
|
public string newUsername { get; set; }
|
||||||
|
[SupplyParameterFromForm]
|
||||||
|
public string newname { get; set; }
|
||||||
// alert
|
// alert
|
||||||
AlertColor alertColor = AlertColor.Primary;
|
AlertColor alertColor = AlertColor.Primary;
|
||||||
IconName alertIconName = IconName.CheckCircleFill;
|
IconName alertIconName = IconName.CheckCircleFill;
|
||||||
bool Hidealert = true;
|
bool Hidealert = true;
|
||||||
string alertMessage = "";
|
string alertMessage = "";
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
if (from == "Verification")
|
||||||
|
{
|
||||||
|
ShowSuccessAlert("تغییر کاربری با موفقیت انجام شد");
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnInitialized() => changepassModel ??= new();
|
await base.OnParametersSetAsync();
|
||||||
|
}
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
newname ??= userinfo.Company.Name;
|
||||||
|
newUsername ??= userinfo.UserName;
|
||||||
|
changepassModel ??= new();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@functions{
|
@functions{
|
||||||
private void ShowDangerAlert(string msg)
|
private void ShowDangerAlert(string msg)
|
||||||
@@ -163,6 +184,54 @@
|
|||||||
ShowDangerAlert(errors[0]);
|
ShowDangerAlert(errors[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private async Task changeUserNameSubmit()
|
||||||
|
{
|
||||||
|
if (newUsername != userinfo.UserName)
|
||||||
|
{
|
||||||
|
var request = await _hc.Get($"User/ChangeUserName/{newUsername}");
|
||||||
|
if (request.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var VerificationID = await request.Content.ReadFromJsonAsync<int>();
|
||||||
|
_hc._nav.NavigateTo($"Verification/{VerificationID}");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var errors = await request.Content.ReadFromJsonAsync<List<string>>();
|
||||||
|
ShowDangerAlert(errors[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private async Task changeNameSubmit()
|
||||||
|
{
|
||||||
|
if (newname != userinfo.Company.Name)
|
||||||
|
{
|
||||||
|
var request = await _hc.Get($"Company/ChangeName/{newname}");
|
||||||
|
if (request.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
if (await request.Content.ReadFromJsonAsync<bool>())
|
||||||
|
{
|
||||||
|
userinfo.FullName= userinfo.Company.Name = newname;
|
||||||
|
ShowSuccessAlert("تغییر نام با موفقیت انجام شد");
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var errors = await request.Content.ReadFromJsonAsync<List<string>>();
|
||||||
|
ShowDangerAlert(errors[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
private async Task changePic(InputFileChangeEventArgs e){
|
private async Task changePic(InputFileChangeEventArgs e){
|
||||||
if (e.GetMultipleFiles()[0].Size <= maxFileSize)
|
if (e.GetMultipleFiles()[0].Size <= maxFileSize)
|
||||||
{
|
{
|
||||||
@@ -197,4 +266,5 @@
|
|||||||
ShowDangerAlert ( "حجم فایل بیشتر از حد مجاز می باشد");
|
ShowDangerAlert ( "حجم فایل بیشتر از حد مجاز می باشد");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -2,6 +2,7 @@
|
|||||||
@page "/Verification/{ID:int}"
|
@page "/Verification/{ID:int}"
|
||||||
@inject HttpClient _hc
|
@inject HttpClient _hc
|
||||||
@inject NavigationManager nav
|
@inject NavigationManager nav
|
||||||
|
@inject UserAuthenticationDTO userinfo
|
||||||
<PageTitle>احراز هویت</PageTitle>
|
<PageTitle>احراز هویت</PageTitle>
|
||||||
<main>
|
<main>
|
||||||
|
|
||||||
@@ -123,7 +124,8 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowDangerAlert(await request.Content.ReadFromJsonAsync<string>());
|
var listerror = await request.Content.ReadFromJsonAsync<List<string>>();
|
||||||
|
ShowDangerAlert(listerror[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -146,6 +148,13 @@
|
|||||||
nav.NavigateTo("/Sign-in/VerificationRegister");
|
nav.NavigateTo("/Sign-in/VerificationRegister");
|
||||||
else if (VerificationCodeModel.Type == "ForgetPassword")
|
else if (VerificationCodeModel.Type == "ForgetPassword")
|
||||||
nav.NavigateTo("/Sign-in/VerificationFrogetPass");
|
nav.NavigateTo("/Sign-in/VerificationFrogetPass");
|
||||||
|
else if (VerificationCodeModel.Type == "ChangeUserName")
|
||||||
|
{
|
||||||
|
userinfo.UserName = VerificationCodeModel.val;
|
||||||
|
|
||||||
|
nav.NavigateTo("/Profile/Verification");
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
nav.NavigateTo("/");
|
nav.NavigateTo("/");
|
||||||
|
|
||||||
@@ -158,7 +167,8 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowDangerAlert(await request.Content.ReadFromJsonAsync<string>());
|
var listerror = await request.Content.ReadFromJsonAsync<List<string>>();
|
||||||
|
ShowDangerAlert(listerror[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +191,8 @@
|
|||||||
{
|
{
|
||||||
if (!successfull)
|
if (!successfull)
|
||||||
await _hc.DeleteAsync($"Verification/Remove/{VerificationCodeModel?.ID}");
|
await _hc.DeleteAsync($"Verification/Remove/{VerificationCodeModel?.ID}");
|
||||||
|
if (VerificationCodeModel.Type == "ChangeUserName")
|
||||||
|
nav.NavigateTo("/Profile");
|
||||||
nav.NavigateTo("/");
|
nav.NavigateTo("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,9 +17,9 @@ builder.Services.AddScoped<HttpClientController>();
|
|||||||
builder.Services.AddScoped(sp => new UserAuthenticationDTO());
|
builder.Services.AddScoped(sp => new UserAuthenticationDTO());
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
||||||
|
|
||||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
||||||
|
|
||||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");
|
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user