-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace TutorLizard.Web.Models | ||
{ | ||
public class EmailSettings | ||
{ | ||
public string MailAddress { get; set; } | ||
public string Password { get; set; } | ||
public string SmtpHost { get; set; } | ||
public int SmtpPort { get; set; } | ||
public string FromAddress { get; set; } | ||
public string FromPassword { get; set; } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,9 @@ | |
using TutorLizard.BusinessLogic.Interfaces.Services; | ||
using TutorLizard.BusinessLogic.Interfaces.Data.Repositories; | ||
using Microsoft.EntityFrameworkCore; | ||
using Newtonsoft.Json; | ||
using TutorLizard.Web.Models; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace TutorLizard.BusinessLogic.Services; | ||
|
||
|
@@ -16,12 +19,14 @@ public class UserAuthenticationService : IUserAuthenticationService | |
private readonly IHttpContextAccessor _httpContextAccessor; | ||
private readonly IUserService _userService; | ||
private readonly JaszczurContext _dbContext; | ||
private readonly EmailSettings _emailSettings; | ||
|
||
public UserAuthenticationService(IHttpContextAccessor httpContextAccessor, IUserService userService, JaszczurContext dbContext) | ||
public UserAuthenticationService(IHttpContextAccessor httpContextAccessor, IUserService userService, JaszczurContext dbContext, IOptions<EmailSettings> emailSettings) | ||
{ | ||
_httpContextAccessor = httpContextAccessor; | ||
_userService = userService; | ||
_dbContext = dbContext; | ||
_emailSettings = emailSettings.Value; | ||
} | ||
|
||
public async Task<bool> LogInAsync(string username, string password) | ||
|
@@ -95,9 +100,10 @@ public Task<bool> RegisterUser(string username, UserType type, string email, str | |
|
||
public void SendActivationEmail(string userEmail, string activationCode) | ||
{ | ||
var fromAddress = new MailAddress("[email protected]", "Tutor Lizard"); | ||
var fromAddress = new MailAddress(_emailSettings.FromAddress, "Tutor Lizard"); | ||
var toAddress = new MailAddress(userEmail); | ||
const string fromPassword = "pvez johg nzwc enjg"; | ||
var fromPassword = _emailSettings.FromPassword; | ||
|
||
string subject = "Aktywacja konta"; | ||
string body = $"Cześć tu zespół Tutor Lizard, \naby aktywować swoje konto, kliknij poniższy link: \nhttp://localhost:7092/Account/ActivateAccount?activationCode={activationCode}"; | ||
|
||
|