employees edit form

This commit is contained in:
Stoyan Zlatev
2023-06-16 11:29:11 +02:00
parent 6f9b448b33
commit bdd730271d
28 changed files with 582 additions and 129 deletions
@@ -1,6 +1,7 @@
namespace LaaProduction.Personalization
{
using LaaProduction.Personalization.Interfaces;
using LaaProduction.Personalization.Models;
using LaaProduction.Personalization.Repositories.Interfaces;
using System;
@@ -49,12 +50,14 @@
public IPrincipal GetClaimsPrincipal(string token)
{
var claimsIdentity = anonymous;
var tokenData = this.employeesRepository.GetTokenData(token);
if (this.employeesRepository.TokenExists(token))
if (tokenData != null)
{
var employee = this.employeesRepository.GetEmployee(token);
var employee = this.employeesRepository.Find(tokenData.EmployeeId);
var claims = new List<Claim>
{
new Claim(nameof(EmployeeToken.AppId), tokenData.AppId.ToString()),
new Claim(nameof(employee.EmployeeId), employee.EmployeeId.ToString()),
new Claim(nameof(employee.FullName), employee.FullName),
new Claim(nameof(employee.Username), employee.Username),
@@ -88,5 +91,14 @@
return new ClaimsPrincipal(claimsIdentity);
}
public void ResetPassword(short employeeId)
{
this.employeesRepository.ResetPassword(employeeId);
this.employeesRepository.ResetTokens(employeeId);
}
public void SetPassword(short employeeId, string password)
=> this.employeesRepository.SetPassword(employeeId, password);
}
}