From 1eea7927a5b76aa6a27725d5188c291c79aee45d Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 23 Feb 2018 11:21:00 +0000 Subject: [PATCH] Fixed #1886 #1865 --- src/Ombi/Controllers/IdentityController.cs | 51 +++++++++++++++++----- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/src/Ombi/Controllers/IdentityController.cs b/src/Ombi/Controllers/IdentityController.cs index 8e28a18c4..7c5730e0c 100644 --- a/src/Ombi/Controllers/IdentityController.cs +++ b/src/Ombi/Controllers/IdentityController.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; using System.Threading.Tasks; - +using System.Web; using AutoMapper; using Hangfire; using Microsoft.AspNetCore.Authorization; @@ -621,25 +621,54 @@ namespace Ombi.Controllers return defaultMessage; } - // We have the user - var token = await UserManager.GeneratePasswordResetTokenAsync(user); - // We now need to email the user with this token - var emailSettings = await EmailSettings.GetSettingsAsync(); + var customizationSettings = await CustomizationSettings.GetSettingsAsync(); var appName = (string.IsNullOrEmpty(customizationSettings.ApplicationName) ? "Ombi" : customizationSettings.ApplicationName); + var emailSettings = await EmailSettings.GetSettingsAsync(); + customizationSettings.AddToUrl("/token?token="); var url = customizationSettings.ApplicationUrl; - await EmailProvider.SendAdHoc(new NotificationMessage + if (user.UserType == UserType.PlexUser) + { + await EmailProvider.SendAdHoc(new NotificationMessage + { + To = user.Email, + Subject = $"{appName} Password Reset", + Message = + $"You recently made a request to reset your {appName} account. Please click the link below to complete the process.

" + + $" Reset " + }, emailSettings); + } + else if (user.UserType == UserType.EmbyUser && user.IsEmbyConnect) { - To = user.Email, - Subject = $"{appName} Password Reset", - Message = $"You recently made a request to reset your {appName} account. Please click the link below to complete the process.

" + - $" Reset " - }, emailSettings); + await EmailProvider.SendAdHoc(new NotificationMessage + { + To = user.Email, + Subject = $"{appName} Password Reset", + Message = + $"You recently made a request to reset your {appName} account.

" + + $"To reset your password you need to go to Emby.Media and then click on your Username > Edit Profile > Email and Password" + }, emailSettings); + } + else + { + // We have the user + var token = await UserManager.GeneratePasswordResetTokenAsync(user); + var encodedToken = WebUtility.UrlEncode(token); + + await EmailProvider.SendAdHoc(new NotificationMessage + { + To = user.Email, + Subject = $"{appName} Password Reset", + Message = + $"You recently made a request to reset your {appName} account. Please click the link below to complete the process.

" + + $" Reset " + }, emailSettings); + } return defaultMessage; }