diff --git a/src/Ombi/ClientApp/app/app.module.ts b/src/Ombi/ClientApp/app/app.module.ts
index 402ebf4e6..8133929fd 100644
--- a/src/Ombi/ClientApp/app/app.module.ts
+++ b/src/Ombi/ClientApp/app/app.module.ts
@@ -47,6 +47,7 @@ const routes: Routes = [
//{ path: 'requests-grid', component: RequestGridComponent },
{ path: 'login', component: LoginComponent },
{ path: 'reset', component: ResetPasswordComponent },
+ { path: 'token', component: TokenResetPasswordComponent },
{ path: 'landingpage', component: LandingPageComponent }
];
diff --git a/src/Ombi/ClientApp/app/login/tokenresetpassword.component.html b/src/Ombi/ClientApp/app/login/tokenresetpassword.component.html
index 3f5fe6819..6d1122df6 100644
--- a/src/Ombi/ClientApp/app/login/tokenresetpassword.component.html
+++ b/src/Ombi/ClientApp/app/login/tokenresetpassword.component.html
@@ -23,13 +23,9 @@ include the remember me checkbox
-
+
-
-
- Forgot the password?
-
diff --git a/src/Ombi/ClientApp/app/login/tokenresetpassword.component.ts b/src/Ombi/ClientApp/app/login/tokenresetpassword.component.ts
index 6d68ff0f2..232457b3c 100644
--- a/src/Ombi/ClientApp/app/login/tokenresetpassword.component.ts
+++ b/src/Ombi/ClientApp/app/login/tokenresetpassword.component.ts
@@ -1,12 +1,13 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
-import { ActivatedRoute } from '@angular/router';
+import { ActivatedRoute, Params } from '@angular/router';
import { FormGroup, Validators, FormBuilder } from '@angular/forms';
import { IdentityService } from '../services/identity.service';
import { NotificationService } from '../services/notification.service';
import { SettingsService } from '../services/settings.service';
import { ICustomizationSettings } from '../interfaces/ISettings';
+import { IResetPasswordToken } from '../interfaces/IUser';
@Component({
templateUrl: './tokenresetpassword.component.html',
@@ -16,8 +17,9 @@ export class TokenResetPasswordComponent implements OnInit {
constructor(private identityService: IdentityService, private router: Router, private route: ActivatedRoute, private notify: NotificationService,
private fb: FormBuilder, private settingsService: SettingsService) {
- this.route.params
- .subscribe(params => {
+ this.route.queryParams
+ .subscribe((params:Params) => {
+ debugger;
this.form = this.fb.group({
email: ["", [Validators.required]],
password: ["", [Validators.required]],
@@ -31,7 +33,7 @@ export class TokenResetPasswordComponent implements OnInit {
customizationSettings: ICustomizationSettings;
- ngOnInit(): void {
+ ngOnInit() : void {
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
}
@@ -41,8 +43,8 @@ export class TokenResetPasswordComponent implements OnInit {
this.notify.error("Validation", "Email address is required");
return
}
-
- this.identityService.resetPassword(form.value).subscribe(x => {
+ var token = form.value as IResetPasswordToken;
+ this.identityService.resetPassword(token).subscribe(x => {
if (x.successful) {
this.notify.success("Success", `Your Password has been reset`)
this.router.navigate(['login']);
diff --git a/src/Ombi/Controllers/IdentityController.cs b/src/Ombi/Controllers/IdentityController.cs
index 2b4883193..3adfb52fb 100644
--- a/src/Ombi/Controllers/IdentityController.cs
+++ b/src/Ombi/Controllers/IdentityController.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net;
using System.Threading.Tasks;
using AutoMapper;
@@ -434,20 +435,23 @@ namespace Ombi.Controllers
}
// We have the user
- var token = await UserManager.GeneratePasswordResetTokenAsync(user);
-
+ var token = await UserManager.GenerateEmailConfirmationTokenAsync(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 url =
+ $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}";
await EmailProvider.Send(new NotificationMessage
{
To = user.Email,
Subject = $"{appName} Password Reset",
Message = $"Hello {user.UserName},
You recently made a request to reset your {appName} account. Please click the link below to complete the process.
" +
- $" Reset "
+ $" Reset "
}, emailSettings);
return defaultMessage;
@@ -461,7 +465,7 @@ namespace Ombi.Controllers
[HttpPost("resetpassword")]
[AllowAnonymous]
[ApiExplorerSettings(IgnoreApi = true)]
- public async Task ResetPassword(ResetPasswordToken token)
+ public async Task ResetPassword([FromBody]ResetPasswordToken token)
{
var user = await UserManager.FindByEmailAsync(token.Email);
@@ -473,8 +477,9 @@ namespace Ombi.Controllers
Errors = new List { "Please check you email." }
};
}
-
- var tokenValid = await UserManager.ResetPasswordAsync(user, token.Token, token.Password);
+ var validToken = WebUtility.UrlDecode(token.Token);
+ validToken = validToken.Replace(" ", "+");
+ var tokenValid = await UserManager.ResetPasswordAsync(user, validToken, token.Password);
if (tokenValid.Succeeded)
{