...
This commit is contained in:
@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
|
||||
namespace Back.Controllers
|
||||
{
|
||||
@@ -59,7 +60,7 @@ namespace Back.Controllers
|
||||
[HttpPost("CreateCsrAndPrivateKey")]
|
||||
public async Task<ActionResult<TaxToolsDTO>> CreateCsrAndPrivateKey(CsrPrivateKeyDto model)
|
||||
{
|
||||
var resultValidationmodel = await _mobilevalidation.ValidateAsync(model.Mobile);
|
||||
var resultValidationmodel = await _mobilevalidation.ValidateAsync(Tuple.Create(model.Mobile,false));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
return Ok(await _sBase.CreateCsrAndPrivateKey(model));
|
||||
@@ -167,6 +168,23 @@ namespace Back.Controllers
|
||||
}
|
||||
|
||||
}
|
||||
[HttpPost("ForgetPassWord")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<string>> ForgetPassWord(ForgetPasswordItem Item)
|
||||
{
|
||||
var resultValidationmodel = await _mobilevalidation.ValidateAsync(Tuple.Create(Item.Username, true));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
var ID = await _servValidatinMsg.GenerateCode(new VerificationCode
|
||||
{
|
||||
prm = Item.Username,
|
||||
val = Item.PassWord,
|
||||
Type = "ForgetPassword"
|
||||
});
|
||||
|
||||
_servSendMsg.Authentication(Item.Username, ID.ToString());
|
||||
return Ok(ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
29
Back/Controllers/CompanyController.cs
Normal file
29
Back/Controllers/CompanyController.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Back.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs;
|
||||
|
||||
namespace Back.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class CompanyController : ControllerBase
|
||||
{
|
||||
private readonly servCompany _servCompany;
|
||||
public CompanyController(servCompany servCompany)
|
||||
{
|
||||
_servCompany = servCompany;
|
||||
}
|
||||
[HttpPost("ChangeLogo")]
|
||||
public async Task<ActionResult<bool>> ChangeLogo(byte[] logo)
|
||||
{
|
||||
//var result = await _sBase.ReadPublicKeyFromCER(modelfromBase64);
|
||||
//if (result.type == "error")
|
||||
// return BadRequest();
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Back.Validations;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -33,7 +34,7 @@ namespace Back.Controllers
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<int>> NewTicketNoAuthentication(CTicketNoAuthenticationDto item)
|
||||
{
|
||||
var resultValidationmodel = await _mobilevalidation.ValidateAsync(item.Mobile);
|
||||
var resultValidationmodel = await _mobilevalidation.ValidateAsync(Tuple.Create(item.Mobile,false));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
|
@@ -37,6 +37,19 @@ namespace Back.Controllers
|
||||
return Ok(result);
|
||||
|
||||
}
|
||||
[HttpPost("ChangePassword")]
|
||||
public async Task<ActionResult<bool>> ChangePassword(ChangePasswordDto item)
|
||||
{
|
||||
if (item.newPass.Trim() != item.renewPass.Trim())
|
||||
return BadRequest(new List<string> { "تکرار کلمه عبور با کلمه عبور مطابقت ندارد" });
|
||||
if (item.newPass.Trim().Length <= 3)
|
||||
return BadRequest(new List<string> { "کلمه عبور جدید باید بیشتر از 3کاراکتر باشد" });
|
||||
var UserID = HttpContext.User.Claims.First(c => c.Type == "UserID").Value;
|
||||
if (!await _servUser.PermissionChangePassword(item.oldPass.Trim(), Convert.ToInt32(UserID)))
|
||||
return BadRequest(new List<string> { "کلمه عبور قبلی صحیح نمی باشد" });
|
||||
return Ok(await _servUser.ChangePassword(item.newPass.Trim(), Convert.ToInt32(UserID)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -17,13 +17,15 @@ namespace Back.Controllers
|
||||
private readonly GetVerificationValidation _getVerificationValidation;
|
||||
private readonly servSendMsg _servSendMsg;
|
||||
private readonly servCompany _servCompany;
|
||||
private readonly servUser _servUser;
|
||||
public VerificationController(ServValidatinMsg servValidatinMsg, GetVerificationValidation getVerificationValidation
|
||||
, servCompany servCompany, servSendMsg servSendMsg)
|
||||
, servCompany servCompany, servSendMsg servSendMsg, servUser servUser)
|
||||
{
|
||||
_servValidatinMsg = servValidatinMsg;
|
||||
_getVerificationValidation = getVerificationValidation;
|
||||
_servCompany = servCompany;
|
||||
_servSendMsg = servSendMsg;
|
||||
_servUser = servUser;
|
||||
}
|
||||
[HttpGet("GetVerification/{ID}")]
|
||||
[AllowAnonymous]
|
||||
@@ -61,6 +63,12 @@ namespace Back.Controllers
|
||||
_servSendMsg.Authentication(company.Mobile, ID.ToString());
|
||||
break;
|
||||
|
||||
|
||||
case "ForgetPassword":
|
||||
var user = await _servUser.ChangePasswordByMobile(_getVerificationValidation.verificationCode.prm, _getVerificationValidation.verificationCode.val);
|
||||
_servSendMsg.Authentication(_getVerificationValidation.verificationCode.prm, ID.ToString());
|
||||
break;
|
||||
|
||||
default:
|
||||
return BadRequest("این نوع احراز تعریف نشده");
|
||||
}
|
||||
|
Reference in New Issue
Block a user