...
This commit is contained in:
@@ -74,7 +74,7 @@ namespace Hushian.Application.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
var exper = await _ExperRepository.Get().FirstOrDefaultAsync(f => f.UserName == auth.Username
|
||||
var exper = await _ExperRepository.Get().Include(inc=>inc.Company).FirstOrDefaultAsync(f => f.UserName == auth.Username
|
||||
&& f.Password == auth.Password.GetHash() && f.Available);
|
||||
if (exper == null)
|
||||
{
|
||||
@@ -85,7 +85,7 @@ namespace Hushian.Application.Services
|
||||
Response.Success = true;
|
||||
Response.Value = new AuthResponse()
|
||||
{
|
||||
Fullname = exper.FullName,
|
||||
Fullname = exper.FullName+" ("+ exper.Company.FullName+")",
|
||||
Id = exper.ID,
|
||||
CompanyId = exper.CompanyID,
|
||||
MobileOrUserName = exper.UserName,
|
||||
|
@@ -70,6 +70,8 @@ namespace Hushian.Application.Services
|
||||
company.Email = model.Email;
|
||||
company.WebSite = model.WebSite;
|
||||
company.logo = model.logo;
|
||||
company.allowBot = model.allowBot;
|
||||
company.Available = model.Available;
|
||||
|
||||
if (await _CompanyRepository.UPDATEBool(company))
|
||||
{
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Common.Dtos.Company;
|
||||
using Common.Dtos;
|
||||
using Common.Dtos.Company;
|
||||
using Hushian.Application.Constants;
|
||||
using Hushian.Application.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -39,6 +40,14 @@ namespace Hushian.WebApi.Controllers.v1
|
||||
return response.Success && response.Value ? NoContent()
|
||||
: BadRequest(response.Errors);
|
||||
}
|
||||
[HttpPut("ChangePasswordCompany")]
|
||||
[Authorize(Roles = "Company")]
|
||||
public async Task<ActionResult> ChangePasswordCompany([FromBody] ChangePasswordDto item)
|
||||
{
|
||||
var response = await _companyService.ChangePasswordCompany(item, Convert.ToInt32(User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First()));
|
||||
return response.Success && response.Value ? NoContent()
|
||||
: BadRequest(response.Errors);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -6,6 +6,8 @@
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject AuthService authService;
|
||||
@inject ILocalStorageService localStorageService;
|
||||
@inject CompanyService companyService
|
||||
|
||||
<form style="background-color: #ffffff; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column;">
|
||||
|
||||
<label style="margin-bottom: 8px; font-size: 14px; color: #333;" for="oldpass">رمز عبور قبلی:</label>
|
||||
@@ -60,7 +62,15 @@
|
||||
}
|
||||
|
||||
SpinnerVisible = true;
|
||||
var result = await userService.ChangePasswordYourself(dto);
|
||||
var result = false;
|
||||
string Role = await localStorageService.GetItem<string>("C/Role");
|
||||
|
||||
if (Role == "Company")
|
||||
result = await companyService.ChangePasswordCompany(dto);
|
||||
|
||||
else if (Role == "Exper")
|
||||
result = await userService.ChangePasswordYourself(dto);
|
||||
|
||||
if (result)
|
||||
{
|
||||
ToastService.Notify(new ToastMessage(ToastType.Success, "تغییر کلمه عبور با موفقیت انجام شد"));
|
||||
|
@@ -27,12 +27,12 @@
|
||||
public Update_ExperDto model { get; set; } = new();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var user=await userService.GetCurrentUser();
|
||||
var user = await userService.GetCurrentExper();
|
||||
if (user!=null)
|
||||
{
|
||||
model.FullName = user.FullName;
|
||||
|
||||
Role = await localStorageService.GetItem<string>("Role");
|
||||
Role = await localStorageService.GetItem<string>("C/Role");
|
||||
isAuthorizedCompanyUser = Role=="Exper" && await userService.CheckAvailableExperInCompany();
|
||||
}
|
||||
else
|
||||
|
@@ -82,20 +82,21 @@
|
||||
public string TitleRole { get; set; } = "";
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Role = await localStorageService.GetItem<string>("C/Role");
|
||||
await CheckOnline();
|
||||
if (isonline)
|
||||
{
|
||||
//Roles = await localStorageService.GetItem<List<string>>("Role");
|
||||
Username = await localStorageService.GetItem<string>("Username");
|
||||
Fullname = await localStorageService.GetItem<string>("Fullname");
|
||||
string UserID = await localStorageService.GetItem<string>("UserID");
|
||||
img = await localStorageService.GetItem<byte[]?>("img");
|
||||
Username = await localStorageService.GetItem<string>("C/Username");
|
||||
Fullname = await localStorageService.GetItem<string>("C/Fullname");
|
||||
string UserID = await localStorageService.GetItem<string>("C/UserID");
|
||||
img = await localStorageService.GetItem<byte[]?>("C/img");
|
||||
}
|
||||
|
||||
|
||||
TitleRole = Role == "Company" ? "مدیر" : "کارشناس";
|
||||
|
||||
isAuthorizedCompanyUser = Role=="Company" || Role=="Exper" && await userService.CheckAvailableExperInCompany();
|
||||
isAuthorizedCompanyUser = Role == "Company" || Role == "Exper" && await userService.CheckAvailableExperInCompany();
|
||||
|
||||
string route = NavigationManager.Uri.Replace(NavigationManager.BaseUri, "").ToLower();
|
||||
if (route.Length > 0)
|
||||
@@ -120,13 +121,6 @@
|
||||
await authService.Logout();
|
||||
NavigationManager.NavigateTo("/login");
|
||||
}
|
||||
private async Task ChangePasword()
|
||||
{
|
||||
var parameters = new Dictionary<string, object>();
|
||||
parameters.Add("Username", Username);
|
||||
await modal.ShowAsync<ChangePassWordComponent>(title: "تغییر رمز عبور", parameters: parameters);
|
||||
|
||||
}
|
||||
private async Task Settings()
|
||||
{
|
||||
var parameters = new Dictionary<string, object>();
|
||||
@@ -134,11 +128,15 @@
|
||||
|
||||
}
|
||||
private async Task EditCurrentUser()
|
||||
{
|
||||
if (Role == "Exper")
|
||||
{
|
||||
var parameters = new Dictionary<string, object>();
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<Update_ExperDto>(this, CallBack));
|
||||
|
||||
await modal.ShowAsync<EditUserYourselfComponent>(title: $"ویرایش کاربر {Username}", parameters: parameters);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
async Task CallBack(Update_ExperDto edit)
|
||||
@@ -148,8 +146,8 @@
|
||||
// await localStorageService.SetItem("img", img);
|
||||
|
||||
Fullname = edit.FullName;
|
||||
await localStorageService.RemoveItem("Fullname");
|
||||
await localStorageService.SetItem("Fullname", Fullname);
|
||||
await localStorageService.RemoveItem("C/Fullname");
|
||||
await localStorageService.SetItem("C/Fullname", Fullname);
|
||||
|
||||
}
|
||||
private void SetActiveMenu(string menu)
|
||||
@@ -189,7 +187,7 @@
|
||||
else
|
||||
{
|
||||
Role = await localStorageService.GetItem<string>("C/Role");
|
||||
if (Role=="User")
|
||||
if (Role == "User")
|
||||
{
|
||||
isonline = false;
|
||||
NavigationManager.NavigateTo("/NotFound");
|
||||
@@ -225,16 +223,24 @@
|
||||
|
||||
private IEnumerable<NavItem> GetNavItems()
|
||||
{
|
||||
if (Role == "Exper")
|
||||
navItems = new List<NavItem>
|
||||
{
|
||||
// new NavItem { Href = "/", IconName = IconName.HouseDoorFill, Text = "خانه"},
|
||||
// new NavItem { Href = "/Conversation", IconName = IconName.ChatText, Text = " گفتگو ها"},
|
||||
new NavItem { Href = "/", IconName = IconName.ChatText, Text = " گفتگو ها"},
|
||||
new NavItem { Href = "/Settings", IconName = IconName.Hammer, Text = " تنظیمات"},
|
||||
};
|
||||
|
||||
else if (Role == "Company")
|
||||
navItems = new List<NavItem>{
|
||||
new NavItem { Href = "/", IconName = IconName.ChatText, Text = " گفتگو ها"},
|
||||
new NavItem { Href = "/UserManagement", IconName = IconName.PersonBoundingBox, Text = " مدیریت کاربران"},
|
||||
new NavItem { Href = "/GroupManagement", IconName = IconName.Grid1X2, Text = " مدیریت گروه ها"},
|
||||
new NavItem { Href = "/Settings", IconName = IconName.Hammer, Text = " تنظیمات"},
|
||||
};
|
||||
|
||||
else navItems = new List<NavItem>();
|
||||
|
||||
|
||||
return navItems;
|
||||
}
|
||||
|
||||
|
@@ -17,13 +17,13 @@
|
||||
<span>به هوشیان</span>
|
||||
</div>
|
||||
|
||||
<div id="primary_form" class="form">
|
||||
<EditForm id="primary_form" class="form" Model="model" OnSubmit="onClick" FormName="LoginForm">
|
||||
<div class=" group w-full">
|
||||
<label for="user-name" class="block mb-2 text-slate-600 font-bold">
|
||||
شماره همراه / نام کاربری
|
||||
</label>
|
||||
<div class="container-input">
|
||||
<input style="text-align:center" type="text" @bind-value="username" id="user-name" maxlength="64" title="نام کاربری را وارد کنید." class="input-form input_vk_1" required="" data-val="true" data-val-required="شماره همراه / نام کاربری را وارد کنید." name="Username">
|
||||
<input style="text-align:center" type="text" @bind-value="model.Username" id="user-name" maxlength="64" title="نام کاربری را وارد کنید." class="input-form input_vk_1" required="" data-val="true" data-val-required="شماره همراه / نام کاربری را وارد کنید." name="Username">
|
||||
</div>
|
||||
</div>
|
||||
<div class="relative group">
|
||||
@@ -31,7 +31,7 @@
|
||||
کلمه عبور
|
||||
</label>
|
||||
<div class="container-input">
|
||||
<input style="text-align:center" @bind-value=Password type="password" id="password" title="کلمه عبور را وارد کنید." maxlength="36" class="input-form input_vk_2" autocomplete="off" required="" data-val="true" data-val-required="کلمه عبور را وارد کنید." name="Password">
|
||||
<input style="text-align:center" @bind-value=model.Password type="password" id="password" title="کلمه عبور را وارد کنید." maxlength="36" class="input-form input_vk_2" autocomplete="off" required="" data-val="true" data-val-required="کلمه عبور را وارد کنید." name="Password">
|
||||
<div class=" flex gap-1 px-1">
|
||||
<div class="cursor-pointer hover:text-black hover:bg-primary hover:bg-opacity-10 rounded transition-all p-1 bg-slate-50 z-10 text-slate-500" onclick="showPassword(event, 'password')">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
@@ -53,7 +53,7 @@
|
||||
</div>
|
||||
<div class=" space-y-5 flex flex-col items-center">
|
||||
|
||||
<Button Loading=Loading LoadingText="در حال ورود ..." Color="ButtonColor.Primary" Type="ButtonType.Submit" @onclick=onClick class="btn-primary w-full mb-4 lg:mb-0">
|
||||
<Button Loading=Loading LoadingText="در حال ورود ..." Color="ButtonColor.Primary" Type="ButtonType.Submit" class="btn-primary w-full mb-4 lg:mb-0">
|
||||
ورود
|
||||
</Button>
|
||||
</div>
|
||||
@@ -64,14 +64,13 @@
|
||||
|
||||
</div>
|
||||
<input name="__RequestVerificationToken" type="hidden" value="CfDJ8P2efyfpaLFHon15HCO5GnTcqzVeJClceMnnP99o04SA4Jbau0j_wcgDQBvHrI3oVb7JTofciu8lxPVwkHOn85rf9-vWzZefUXIBfzQb9upg_bF2ZDxTduIs62mLs07I48u7WZpLohGSjdmJTjjcCQY">
|
||||
</div>
|
||||
</EditForm>
|
||||
@code {
|
||||
[Inject] protected ToastService ToastService { get; set; } = default!;
|
||||
private ConfirmDialog dialog = default!;
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
AuthRequestFromCompanySide model { get; set; } = new();
|
||||
private Modal modal = default!;
|
||||
public string username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool Loading { get; set; }
|
||||
}
|
||||
@functions {
|
||||
@@ -80,20 +79,10 @@
|
||||
|
||||
async Task onClick()
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(Password)) return;
|
||||
if (string.IsNullOrEmpty(model.Username) || string.IsNullOrEmpty(model.Password)) return;
|
||||
Loading = true;
|
||||
var msg = await auth.login(new AuthRequestFromCompanySide()
|
||||
{
|
||||
Username = username,
|
||||
Password = Password
|
||||
});
|
||||
if (msg == "ok")
|
||||
{
|
||||
navigationManager.NavigateTo("/");
|
||||
}
|
||||
|
||||
|
||||
var msg = await auth.login(model);
|
||||
if (msg == "ok") navigationManager.NavigateTo("/");
|
||||
|
||||
Loading = false;
|
||||
}
|
||||
|
@@ -40,8 +40,8 @@
|
||||
</style>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row row-fullheight">
|
||||
|
||||
@* <div class="row row-fullheight"> *@
|
||||
<div class="row">
|
||||
<!-- تغییر کلمه عبور -->
|
||||
<div class="col-md-6 d-flex flex-column" style="height: fit-content;">
|
||||
<div class="section-box w-100">
|
||||
@@ -101,7 +101,7 @@
|
||||
}
|
||||
|
||||
|
||||
<!-- پایین چپ -->
|
||||
@* <!-- پایین چپ -->
|
||||
<div class="col-md-6 d-flex flex-column">
|
||||
<div class="section-box w-100">
|
||||
<div class="section-title">
|
||||
@@ -119,7 +119,7 @@
|
||||
</div>
|
||||
<!-- محتوای دلخواه -->
|
||||
</div>
|
||||
</div>
|
||||
</div> *@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -127,15 +127,17 @@
|
||||
@code {
|
||||
[Inject] protected ToastService ToastService { get; set; } = default!;
|
||||
|
||||
bool ALLOWcompanyinfo = true;
|
||||
bool ALLOWcompanyinfo = false;
|
||||
public bool loading { get; set; } = false;
|
||||
public ReadANDUpdate_CompanyDto dto { get; set; }
|
||||
= new();
|
||||
int CompanyID = 0;
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (await localStorageService.GetItem<string>("Role") != "Company")
|
||||
if (await localStorageService.GetItem<string>("C/Role") == "User")
|
||||
navigationManager.NavigateTo("/NotFound");
|
||||
|
||||
ALLOWcompanyinfo = await localStorageService.GetItem<string>("C/Role") == "Company";
|
||||
CompanyID= await localStorageService.GetItem<int>("C/CompanyId");
|
||||
|
||||
dto = await companyService.GetCompany(CompanyID);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Common.Dtos.Company;
|
||||
using Common.Dtos;
|
||||
using Common.Dtos.Company;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace HushianWebApp.Service
|
||||
@@ -35,6 +36,11 @@ namespace HushianWebApp.Service
|
||||
var response = await _baseController.Put($"{BaseRoute}UpdateCompany",dto);
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
public async Task<bool> ChangePasswordCompany(ChangePasswordDto request)
|
||||
{
|
||||
var response = await _baseController.Put($"{BaseRoute}ChangePasswordCompany", request);
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
//public async Task<bool> AddContentInfo(string str)
|
||||
//{
|
||||
// var response = await _baseController.Post($"{BaseRoute}AddContentInfo?ContentInfo={str}");
|
||||
|
@@ -46,9 +46,9 @@ namespace HushianWebApp.Service
|
||||
var response = await _baseController.Put($"{BaseRoute}EditUserYourself", request);
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
public async Task<Read_ExperDto?> GetCurrentUser() //ویرایش کاربران توسط خود
|
||||
public async Task<Read_ExperDto?> GetCurrentExper() //ویرایش کاربران توسط خود
|
||||
{
|
||||
var response = await _baseController.Get($"{BaseRoute}GetCurrentUser");
|
||||
var response = await _baseController.Get($"{BaseRoute}GetCurrentExper");
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return await response.Content.ReadFromJsonAsync<Read_ExperDto>();
|
||||
|
Reference in New Issue
Block a user