...
This commit is contained in:
@@ -11,31 +11,33 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using Hushian.Application.Models.Message;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Hushian.Application.Services
|
||||
{
|
||||
public class VerificationService
|
||||
{
|
||||
private readonly JwtSettings _jwtSettings;
|
||||
private readonly IGenericRepository<VerificationCode> _VerificationCodeRepository;
|
||||
private readonly IGenericRepository<Company> _CompanyRepository;
|
||||
private readonly IGenericRepository<Exper> _ExperRepository;
|
||||
private readonly IMessageSender _messageSender;
|
||||
private readonly IGenericRepository<User> _UserRepository;
|
||||
private readonly AuthService _authService;
|
||||
|
||||
public VerificationService(IGenericRepository<VerificationCode> verificationCodeRepository
|
||||
, IMessageSender messageSender
|
||||
, IGenericRepository<User> userRepository
|
||||
, AuthService authService
|
||||
, IGenericRepository<Company> companyRepository
|
||||
, IGenericRepository<Exper> experRepository)
|
||||
, IGenericRepository<Exper> experRepository
|
||||
, IOptions<JwtSettings> jwtSettings)
|
||||
{
|
||||
_VerificationCodeRepository = verificationCodeRepository;
|
||||
_messageSender = messageSender;
|
||||
_UserRepository = userRepository;
|
||||
_authService = authService;
|
||||
_CompanyRepository = companyRepository;
|
||||
_ExperRepository = experRepository;
|
||||
_jwtSettings = jwtSettings.Value;
|
||||
}
|
||||
|
||||
public async Task<int> GenerateCodeForLoginUser(string Mobile)
|
||||
@@ -93,7 +95,7 @@ namespace Hushian.Application.Services
|
||||
Id = User.ID,
|
||||
MobileOrUserName = User.Mobile,
|
||||
Role="User",
|
||||
Token = new JwtSecurityTokenHandler().WriteToken(await _authService.GenerateToken(User.Mobile, User.ID, "User"))
|
||||
Token = new JwtSecurityTokenHandler().WriteToken(_jwtSettings.GenerateToken(User.Mobile, User.ID, "User"))
|
||||
};
|
||||
}
|
||||
else
|
||||
@@ -156,7 +158,7 @@ namespace Hushian.Application.Services
|
||||
Role = "Company",
|
||||
img = anyCompany.logo,
|
||||
MobileOrUserName = anyCompany.Mobile,
|
||||
Token = new JwtSecurityTokenHandler().WriteToken(await _authService.GenerateToken(anyCompany.Mobile, anyCompany.ID, "Company"))
|
||||
Token = new JwtSecurityTokenHandler().WriteToken(_jwtSettings.GenerateToken(anyCompany.Mobile, anyCompany.ID, "Company"))
|
||||
};
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user