This commit is contained in:
mmrbnjd
2024-04-29 07:58:41 +03:30
parent fd13de3e1d
commit 7b8127dc72
23 changed files with 526 additions and 39 deletions

View File

@@ -103,9 +103,9 @@ namespace Back.Services
public async Task<bool> ExistMobileAndCompanyIsActive(string mobile)
{
return await _repoCompany.GetAll().AnyAsync(w => w.Mobile == mobile && w.IsActive);
}
}
}

View File

@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using Shared.DTOs;
using System.IdentityModel.Tokens.Jwt;
using System.Reflection;
using System.Security.Claims;
using System.Text;
@@ -56,7 +57,7 @@ namespace Back.Services
return null;
string Jwt_Lifetime_Minutes = await GetJwt_Lifetime_Minutes();
ret.UserName = user.Username;
ret.Token =newtoken ? await CerateToken(user.ID, user.Username, Jwt_Lifetime_Minutes) : user.Token;
ret.FullName = user.Fullname;
ret.Photo = user.Photo==null ? null : Convert.ToBase64String(user.Photo);
@@ -175,7 +176,14 @@ namespace Back.Services
await _RepoUser.UpdateAsync(user);
}
}
public async Task<bool> ChangePasswordByMobile(string mobile, string newpassword)
{
var user =await GetUserByUsername(mobile);
if (user == null)
return false;
user.Password = newpassword.encrypted();
return await _RepoUser.UpdateAsync(user);
}
public async Task<DashBoardDTO> GetDashBoard(int CompanyID,int UserID)
{
DashBoardDTO request=new DashBoardDTO();
@@ -237,6 +245,19 @@ namespace Back.Services
//});
return await _RepoUser.UpdateByObjAsync(user);
}
public async Task<bool> ChangePassword(string newPass, int UserID)
{
var user = await GetUserByUserID(UserID);
if (user == null)
return false;
user.Password = newPass.encrypted();
return await _RepoUser.UpdateAsync(user);
}
public async Task<bool> PermissionChangePassword(string oldPass,int UserID)
{
return await _RepoUser.GetAll().AnyAsync(w => w.ID == UserID && w.Password==oldPass.encrypted() && w.IsActive);
}
//--------internal
private async Task<string> GetJwt_Lifetime_Minutes()
{