...
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
Reference in New Issue
Block a user