Updated stuff

pull/1488/head
Jamie.Rees 7 years ago
parent 00aa450309
commit 00c88ab1ed

@ -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 }
];

@ -23,13 +23,9 @@ include the remember me checkbox
<input type="email" id="inputEmail" class="form-control" formControlName="email" placeholder="Email Address" autofocus>
<input type="password" class="form-control" formControlName="password">
<input type="password" class="form-control" formControlName="confirmPassword">
<button class="btn btn-success-outline" [disabled]="form.invalid || !captcha" type="submit">Reset Password</button>
<button class="btn btn-success-outline" [disabled]="form.invalid" type="submit">Reset Password</button>
</form>
<!-- /form -->
<a href="#" class="forgot-password">
Forgot the password?
</a>
</div>
<!-- /card-container -->
</div>

@ -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']);

@ -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}, <br/> You recently made a request to reset your {appName} account. Please click the link below to complete the process.<br/><br/>" +
$"<a href=\"{UserSettings.Value.WebsiteUrl}/reset/{token}\"> Reset </a>"
$"<a href=\"{url}/token?token={token}\"> Reset </a>"
}, emailSettings);
return defaultMessage;
@ -461,7 +465,7 @@ namespace Ombi.Controllers
[HttpPost("resetpassword")]
[AllowAnonymous]
[ApiExplorerSettings(IgnoreApi = true)]
public async Task<OmbiIdentityResult> ResetPassword(ResetPasswordToken token)
public async Task<OmbiIdentityResult> ResetPassword([FromBody]ResetPasswordToken token)
{
var user = await UserManager.FindByEmailAsync(token.Email);
@ -473,8 +477,9 @@ namespace Ombi.Controllers
Errors = new List<string> { "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)
{

Loading…
Cancel
Save