ver
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>
|
||||||
|
|
||||||
|
38
Back/Controllers/VerificationController.cs
Normal file
38
Back/Controllers/VerificationController.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using Back.Data.Models;
|
||||||
|
using Back.Services;
|
||||||
|
using Back.Validations;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Shared.DTOs;
|
||||||
|
|
||||||
|
namespace Back.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class VerificationController : ControllerBase
|
||||||
|
{
|
||||||
|
//private readonly ServValidatinMsg _servValidatinMsg;
|
||||||
|
private readonly GetVerificationValidation _getVerificationValidation;
|
||||||
|
public VerificationController(/*ServValidatinMsg servValidatinMsg, */GetVerificationValidation getVerificationValidation)
|
||||||
|
{
|
||||||
|
//_servValidatinMsg = servValidatinMsg;
|
||||||
|
_getVerificationValidation = getVerificationValidation;
|
||||||
|
|
||||||
|
}
|
||||||
|
[HttpGet("GetVerification/{ID}")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<ActionResult<VerificationCode>> GetVerification(int ID)
|
||||||
|
{
|
||||||
|
var resultValidationmodel = await _getVerificationValidation.ValidateAsync(ID);
|
||||||
|
if (!resultValidationmodel.IsValid)
|
||||||
|
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||||
|
|
||||||
|
return Ok(new VerificationCodeDto {
|
||||||
|
prm= _getVerificationValidation.verificationCode.prm,
|
||||||
|
Type= _getVerificationValidation.verificationCode.Type,
|
||||||
|
val= _getVerificationValidation.verificationCode.val
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -23,6 +23,7 @@ builder.Services.AddScoped<MobileValidation> ();
|
|||||||
builder.Services.AddScoped<Service.Main>();
|
builder.Services.AddScoped<Service.Main>();
|
||||||
builder.Services.AddScoped<servTicket > ();
|
builder.Services.AddScoped<servTicket > ();
|
||||||
builder.Services.AddScoped < ServValidatinMsg>();
|
builder.Services.AddScoped < ServValidatinMsg>();
|
||||||
|
builder.Services.AddScoped<GetVerificationValidation> ();
|
||||||
string origins = "OriginTaxPayer";
|
string origins = "OriginTaxPayer";
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
|
@@ -16,14 +16,14 @@ namespace Back.Services
|
|||||||
return await _verificationCodeRepo.Get(w => w.prm == Prm).FirstOrDefaultAsync();
|
return await _verificationCodeRepo.Get(w => w.prm == Prm).FirstOrDefaultAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
public async Task<VerificationCode> GetRegistrationCode(int ID)
|
public async Task<VerificationCode> GetVerificationCode(int ID)
|
||||||
{
|
{
|
||||||
return await _verificationCodeRepo.Get(w => w.ID == ID).FirstOrDefaultAsync();
|
return await _verificationCodeRepo.Get(w => w.ID == ID).FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
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 GetRegistrationCode(code.ID) != null)
|
while (await GetVerificationCode(code.ID) != null)
|
||||||
code.Code = Random.Shared.Next(1000, 9000);
|
code.Code = Random.Shared.Next(1000, 9000);
|
||||||
|
|
||||||
|
|
||||||
|
26
Back/Validations/GetVerificationValidation.cs
Normal file
26
Back/Validations/GetVerificationValidation.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Back.Data.Models;
|
||||||
|
using Back.Services;
|
||||||
|
using FluentValidation;
|
||||||
|
using Shared.DTOs;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Back.Validations
|
||||||
|
{
|
||||||
|
public class GetVerificationValidation : AbstractValidator<int>
|
||||||
|
{
|
||||||
|
public VerificationCode verificationCode { get; set; }
|
||||||
|
public GetVerificationValidation(ServValidatinMsg _servValidatinMsg)
|
||||||
|
{
|
||||||
|
CascadeMode = CascadeMode.Stop;
|
||||||
|
RuleFor(model => model)
|
||||||
|
.Custom((model, context) => {
|
||||||
|
verificationCode= _servValidatinMsg.GetVerificationCode(model).Result;
|
||||||
|
if (verificationCode==null)
|
||||||
|
context.AddFailure("کد یافت نشد");
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,63 +1,75 @@
|
|||||||
@using Shared.DTOs
|
@using Shared.DTOs
|
||||||
@page "/Verification/{ID:int}"
|
@page "/Verification/{ID:int}"
|
||||||
|
@inject HttpClient _hc
|
||||||
|
@inject NavigationManager nav
|
||||||
|
<PageTitle>احراز هویت</PageTitle>
|
||||||
<main>
|
<main>
|
||||||
<div class="limiter">
|
|
||||||
<div class="container-login100">
|
|
||||||
<div class="wrap-login100 p-t-50 p-b-90">
|
|
||||||
<form method="post" class="login100-form validate-form flex-sb flex-w">
|
|
||||||
<input type="hidden" asp-for="Code" />
|
|
||||||
<input type="hidden" asp-for="Type" />
|
|
||||||
<span class="login100-form-title p-b-51" id="sty1">
|
|
||||||
احراز هویت
|
|
||||||
</span>
|
|
||||||
@* <div class="container-login100-form-btn m-t-17">
|
|
||||||
<h5 class="success">کد ارسال شده به شماره @Model.Mobile</h5>
|
|
||||||
</div> *@
|
|
||||||
|
|
||||||
|
<!-- tp-banner-area-start -->
|
||||||
|
<div class="signin-banner-area signin-banner-main-wrap d-flex align-items-center">
|
||||||
|
<div class="signin-banner-left-box signin-banner-bg p-relative">
|
||||||
|
|
||||||
|
<div class="signin-banner-left-wrap">
|
||||||
|
<div class="pt-20 pb-20">
|
||||||
|
<div class="signin-banner-title-box">
|
||||||
|
<h4>
|
||||||
|
برای ادامه نیاز است هویت شما تائید شود
|
||||||
|
</h4>
|
||||||
|
<h6 style="color:red;">
|
||||||
|
کد ارسالی را وارد نمایید
|
||||||
|
</h6>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="signin-banner-img-box position-relative">
|
||||||
|
<div class="signin-banner-img signin-img-1 d-none d-md-block z-index-3">
|
||||||
|
<img src="img/login/login-2.png" alt="">
|
||||||
|
</div>
|
||||||
|
<div class="signin-banner-img signin-img-2 d-none d-md-block">
|
||||||
|
<img src="img/login/login-1.png" alt="">
|
||||||
|
</div>
|
||||||
|
<div class="signin-banner-img signin-img-3 d-none d-md-block z-index-5">
|
||||||
|
<img src="img/login/login-3.png" alt="">
|
||||||
|
</div>
|
||||||
|
<div class="signin-banner-img signin-img-4 d-none d-sm-block">
|
||||||
|
<img src="img/login/login-4.png" alt="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="signin-banner-from d-flex justify-content-center align-items-center">
|
||||||
|
<div class="signin-banner-from-wrap">
|
||||||
|
<div class="signin-banner-title-box">
|
||||||
|
<h4 class="signin-banner-from-title">احراز هویت</h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="signin-banner-from-box">
|
||||||
|
|
||||||
<EditForm Model="Code" OnSubmit="Submit">
|
<EditForm Model="Code" OnSubmit="Submit">
|
||||||
<DataAnnotationsValidator />
|
<div class="row">
|
||||||
<div class="postbox__comment-input mb-30">
|
<div class="col-12">
|
||||||
<InputNumber @bind-Value="Code" id="cn" type="text" class="inputText" required="" />
|
<div class="postbox__comment-input mb-30">
|
||||||
<span class="floating-label">کد تائید</span>
|
<InputNumber @bind-Value="Code" id="Code" type="text" class="form-control text-center" required="" />
|
||||||
</div>
|
<span class="floating-label">کد تائید</span>
|
||||||
</EditForm>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="signin-banner-from-btn mb-20">
|
||||||
|
<button type="submit" class="signin-btn ">احراز</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</EditForm>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="signin-banner-from-register">
|
||||||
|
<NavLink href="Register">کد ارسال نشد؟ <span>ارسال مجدد</span></NavLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- tp-banner-area-end -->
|
||||||
|
|
||||||
@*
|
|
||||||
<div class="container-login100-form-btn m-t-17">
|
|
||||||
<div class="wrap-input100 validate-input m-b-16" id="sty1" data-validate="کد الزامی می باشد">
|
|
||||||
<input asp-for=VerificationCode id="sty1" class="input100" type="text" name="VerificationCode" placeholder="کد تائید">
|
|
||||||
<span class="focus-input100"></span>
|
|
||||||
</div>
|
|
||||||
<span class="error" asp-validation-for="VerificationCode"></span>
|
|
||||||
</div> *@
|
|
||||||
@* <a href="/ResendMsg/?type=@Model.Type&Code=@Model.Code&Mobile=@Model.Mobile" class="txt1">
|
|
||||||
ارسال مجدد
|
|
||||||
</a> *@
|
|
||||||
<div class="container-login100-form-btn m-t-17">
|
|
||||||
<button class="login100-form-btn" id="sty1">
|
|
||||||
احراز
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="container-login100-form-btn m-t-17">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<a href="/login" class="txt1">
|
|
||||||
ورود به حساب کاربری
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<a href="/Register" class="txt1">
|
|
||||||
ثبت نام
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="dropDownSelect1"></div>
|
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
@@ -70,6 +82,18 @@
|
|||||||
public VerificationCodeDto Model { get; set; }
|
public VerificationCodeDto Model { get; set; }
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
|
var request = await _hc.GetAsync($"Verification/GetVerification/{ID}");
|
||||||
|
if (request.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
|
||||||
|
Model = await request.Content.ReadFromJsonAsync<VerificationCodeDto>();
|
||||||
|
// nav.NavigateTo($"Verification/{res}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nav.NavigateTo($"/");
|
||||||
|
}
|
||||||
|
|
||||||
await base.OnParametersSetAsync();
|
await base.OnParametersSetAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,9 +7,9 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
|||||||
builder.RootComponents.Add<App>("#app");
|
builder.RootComponents.Add<App>("#app");
|
||||||
builder.RootComponents.Add<HeadOutlet>("head::after");
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
||||||
|
|
||||||
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