...
This commit is contained in:
@@ -24,11 +24,6 @@ namespace Back.Controllers
|
||||
if (!ModelState.IsValid) return BadRequest(model);
|
||||
var result = await _servUser.UserAuthentication(model.Username, model.Password);
|
||||
if (result != null) return Ok(result);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else return NotFound("کاربری با این مشخصات یافت نشد");
|
||||
|
||||
|
||||
|
@@ -59,69 +59,76 @@ namespace Back.Services
|
||||
ret.Token =await CerateToken(user.ID, user.Username);
|
||||
ret.FullName = user.Fullname;
|
||||
ret.Photo = user.Photo==null ? null : Convert.ToBase64String(user.Photo);
|
||||
foreach (var rol in user.RolUsers)
|
||||
//foreach (var rol in user.RolUsers)
|
||||
//{
|
||||
// if (!rol.Company.IsActive)
|
||||
// continue;
|
||||
|
||||
// List<PermissionAuthenticationDTO> permissions = new List<PermissionAuthenticationDTO>();
|
||||
// foreach (var per in rol.Company.PermissionPeriods)
|
||||
// {
|
||||
// bool _accessibility = await _checkPermission.AllowPermission(user.ID, rol.CompanyID, per.Permission.ID);
|
||||
|
||||
// #region Child
|
||||
|
||||
// List<Permission> Chidpermissions = _accessibility ? await _servPermission.GetChildPermission(per.Permission.ID):new List<Permission>();
|
||||
// List<PermissionAuthenticationDTO> ChildpermissionAuthenticationDTOs = new List<PermissionAuthenticationDTO>();
|
||||
// foreach (Permission childper in Chidpermissions)
|
||||
// {
|
||||
// bool _childaccessibility = await _checkPermission.AllowPermission(user.ID, rol.CompanyID, childper.ID);
|
||||
// PermissionAuthenticationDTO ChildpermissionAuthenticationDTO = new PermissionAuthenticationDTO
|
||||
// {
|
||||
// ID = childper.ID,
|
||||
// ParentID = childper.ParentID,
|
||||
// Title = childper.Title,
|
||||
// accessibility = _childaccessibility,
|
||||
// //TODO
|
||||
// ChildPermissions = null
|
||||
// };
|
||||
// ChildpermissionAuthenticationDTOs.Add(ChildpermissionAuthenticationDTO);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// PermissionAuthenticationDTO permissionAuthenticationDTO = new PermissionAuthenticationDTO
|
||||
// {
|
||||
// ID = per.Permission.ID,
|
||||
// ParentID = per.Permission.ParentID,
|
||||
// Title = per.Permission.Title,
|
||||
// accessibility = _accessibility,
|
||||
// //TODO
|
||||
// ChildPermissions = ChildpermissionAuthenticationDTOs
|
||||
|
||||
// //Period=new PeriodDTO()
|
||||
// //{
|
||||
// // CalculationTypeID = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.CalculationType.ID).FirstOrDefault(),
|
||||
// // CalculationTypeTitle = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.CalculationType.Title).FirstOrDefault(),
|
||||
// // RemainingAmount = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.RemainingAmount).FirstOrDefault(),
|
||||
// // TotalAmount = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.TotalAmount).FirstOrDefault()
|
||||
// //}
|
||||
|
||||
// };
|
||||
// permissions.Add(permissionAuthenticationDTO);
|
||||
// }
|
||||
|
||||
// ret.Companies.Add(new CompanyAuthenticationDTO
|
||||
// {
|
||||
// ID = rol.CompanyID,
|
||||
// Name = rol.Company.Name,
|
||||
// IsAdmin = rol.IsAdmin,
|
||||
// Logo= rol.Company.Logo == null ? null : Convert.ToBase64String(rol.Company.Logo)
|
||||
|
||||
// /*, permissions = permissions*/
|
||||
// });
|
||||
|
||||
//}
|
||||
ret.Company = new CompanyAuthenticationDTO
|
||||
{
|
||||
if (!rol.Company.IsActive)
|
||||
continue;
|
||||
|
||||
List<PermissionAuthenticationDTO> permissions = new List<PermissionAuthenticationDTO>();
|
||||
foreach (var per in rol.Company.PermissionPeriods)
|
||||
{
|
||||
bool _accessibility = await _checkPermission.AllowPermission(user.ID, rol.CompanyID, per.Permission.ID);
|
||||
|
||||
#region Child
|
||||
|
||||
List<Permission> Chidpermissions = _accessibility ? await _servPermission.GetChildPermission(per.Permission.ID):new List<Permission>();
|
||||
List<PermissionAuthenticationDTO> ChildpermissionAuthenticationDTOs = new List<PermissionAuthenticationDTO>();
|
||||
foreach (Permission childper in Chidpermissions)
|
||||
{
|
||||
bool _childaccessibility = await _checkPermission.AllowPermission(user.ID, rol.CompanyID, childper.ID);
|
||||
PermissionAuthenticationDTO ChildpermissionAuthenticationDTO = new PermissionAuthenticationDTO
|
||||
{
|
||||
ID = childper.ID,
|
||||
ParentID = childper.ParentID,
|
||||
Title = childper.Title,
|
||||
accessibility = _childaccessibility,
|
||||
//TODO
|
||||
ChildPermissions = null
|
||||
};
|
||||
ChildpermissionAuthenticationDTOs.Add(ChildpermissionAuthenticationDTO);
|
||||
}
|
||||
#endregion
|
||||
|
||||
PermissionAuthenticationDTO permissionAuthenticationDTO = new PermissionAuthenticationDTO
|
||||
{
|
||||
ID = per.Permission.ID,
|
||||
ParentID = per.Permission.ParentID,
|
||||
Title = per.Permission.Title,
|
||||
accessibility = _accessibility,
|
||||
//TODO
|
||||
ChildPermissions = ChildpermissionAuthenticationDTOs
|
||||
|
||||
//Period=new PeriodDTO()
|
||||
//{
|
||||
// CalculationTypeID = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.CalculationType.ID).FirstOrDefault(),
|
||||
// CalculationTypeTitle = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.CalculationType.Title).FirstOrDefault(),
|
||||
// RemainingAmount = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.RemainingAmount).FirstOrDefault(),
|
||||
// TotalAmount = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.TotalAmount).FirstOrDefault()
|
||||
//}
|
||||
|
||||
};
|
||||
permissions.Add(permissionAuthenticationDTO);
|
||||
}
|
||||
|
||||
ret.Companies.Add(new CompanyAuthenticationDTO
|
||||
{
|
||||
ID = rol.CompanyID,
|
||||
Name = rol.Company.Name,
|
||||
IsAdmin = rol.IsAdmin,
|
||||
Logo= rol.Company.Logo == null ? null : Convert.ToBase64String(rol.Company.Logo)
|
||||
|
||||
/*, permissions = permissions*/
|
||||
});
|
||||
|
||||
}
|
||||
ID = user.RolUsers.First().ID,
|
||||
Name = user.RolUsers.First().Company.Name,
|
||||
IsAdmin = user.RolUsers.First().IsAdmin,
|
||||
Logo = user.RolUsers.First().Company.Logo == null ? null : Convert.ToBase64String(user.RolUsers.First().Company.Logo)
|
||||
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
public async Task<User> AddUser(User item)
|
||||
|
@@ -1,8 +1,13 @@
|
||||
namespace Shared.DTOs
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class Authentication
|
||||
{
|
||||
[MinLength(3,ErrorMessage =("نام کاربری باید حداقل 3 کاراکتر باشد"))]
|
||||
public string Username { get; set; }
|
||||
[MinLength(3, ErrorMessage = ("کلمه عبور باید حداقل 3 کاراکتر باشد"))]
|
||||
public string Password { get; set; }
|
||||
public bool Remember { get; set; }=false;
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ namespace Shared.DTOs
|
||||
public string FullName { get; set; }
|
||||
public string Token { get; set; }
|
||||
public string Photo { get; set; }
|
||||
public ICollection<CompanyAuthenticationDTO> Companies { get; set; } = new List<CompanyAuthenticationDTO>();
|
||||
public CompanyAuthenticationDTO Company { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
@page "/Sign-in"
|
||||
@using Shared.DTOs
|
||||
|
||||
<PageTitle>ورود</PageTitle>
|
||||
<main>
|
||||
@@ -11,9 +12,9 @@
|
||||
</div>
|
||||
<div class="signin-banner-left-wrap">
|
||||
<div class="signin-banner-title-box mb-100">
|
||||
<h4 class="signin-banner-title">
|
||||
خوش آمدید به <br>
|
||||
سیستم یکپارچه ما
|
||||
<br />
|
||||
<h4 class="signin-banner-title" style="color:black">
|
||||
برای استفاده از بخش ها <br /> وارد شوید
|
||||
</h4>
|
||||
</div>
|
||||
<div class="signin-banner-img-box position-relative">
|
||||
@@ -39,17 +40,24 @@
|
||||
</div>
|
||||
|
||||
<div class="signin-banner-from-box">
|
||||
<form action="#">
|
||||
<EditForm Model="Model" OnValidSubmit="OnLoginClick">
|
||||
<DataAnnotationsValidator />
|
||||
<div class="postbox__comment-input mb-35">
|
||||
<ValidationMessage For="()=>Model.Username" />
|
||||
<ValidationMessage For="()=>Model.Password" />
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="postbox__comment-input mb-30">
|
||||
<input type="text" class="inputText" required="">
|
||||
<span class="floating-label">ایمیل شما</span>
|
||||
<InputText @bind-Value="Model.Username" id="Username" type="text" class="inputText" required="" />
|
||||
|
||||
<span class="floating-label">نام کاربری</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="postbox__comment-input mb-30">
|
||||
<input id="myInput" class="inputText password" type="password" required="">
|
||||
<InputText @bind-Value="Model.Password" id="Password" class="inputText password" type="password" required="" />
|
||||
<span class="floating-label">گذرواژه</span>
|
||||
<span id="click" class="eye-btn">
|
||||
<span class="eye-on">
|
||||
@@ -75,13 +83,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="signin-banner-form-remember">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="postbox__comment-agree">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
|
||||
<InputCheckbox @bind-Value="Model.Remember" id="Remember" class="form-check-input" type="checkbox" />
|
||||
<label class="form-check-label" for="flexCheckDefault">
|
||||
مرا به یاد داشته باش
|
||||
</label>
|
||||
@@ -98,6 +106,7 @@
|
||||
<div class="signin-banner-from-btn mb-20">
|
||||
<button class="signin-btn ">ورود</button>
|
||||
</div>
|
||||
</EditForm>
|
||||
<div class="signin-banner-from-register">
|
||||
<NavLink href="Register">اکانت ندارید؟ <span>ثبت نام</span></NavLink>
|
||||
</div>
|
||||
@@ -110,5 +119,26 @@
|
||||
</main>
|
||||
|
||||
@code {
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
public Authentication? Model { get; set; }
|
||||
protected override void OnInitialized() => Model ??= new();
|
||||
}
|
||||
@functions {
|
||||
|
||||
private async Task OnLoginClick()
|
||||
{
|
||||
var request = await _hc.PostAsJsonAsync("User/authenticate", Model);
|
||||
// if (request.IsSuccessStatusCode)
|
||||
// {
|
||||
// messageStore?.Clear();
|
||||
// var VerificationID = await request.Content.ReadFromJsonAsync<int>();
|
||||
// nav.NavigateTo($"Verification/{VerificationID}");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var error = await request.Content.ReadFromJsonAsync<List<string>>();
|
||||
// messageStore?.Add(() => model.Mobile, error);
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user