mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -07:00
Updated stuff
This commit is contained in:
parent
00aa450309
commit
00c88ab1ed
4 changed files with 21 additions and 17 deletions
|
@ -47,6 +47,7 @@ const routes: Routes = [
|
||||||
//{ path: 'requests-grid', component: RequestGridComponent },
|
//{ path: 'requests-grid', component: RequestGridComponent },
|
||||||
{ path: 'login', component: LoginComponent },
|
{ path: 'login', component: LoginComponent },
|
||||||
{ path: 'reset', component: ResetPasswordComponent },
|
{ path: 'reset', component: ResetPasswordComponent },
|
||||||
|
{ path: 'token', component: TokenResetPasswordComponent },
|
||||||
{ path: 'landingpage', component: LandingPageComponent }
|
{ 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="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="password">
|
||||||
<input type="password" class="form-control" formControlName="confirmPassword">
|
<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>
|
||||||
<!-- /form -->
|
|
||||||
<a href="#" class="forgot-password">
|
|
||||||
Forgot the password?
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /card-container -->
|
<!-- /card-container -->
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute, Params } from '@angular/router';
|
||||||
import { FormGroup, Validators, FormBuilder } from '@angular/forms';
|
import { FormGroup, Validators, FormBuilder } from '@angular/forms';
|
||||||
|
|
||||||
import { IdentityService } from '../services/identity.service';
|
import { IdentityService } from '../services/identity.service';
|
||||||
import { NotificationService } from '../services/notification.service';
|
import { NotificationService } from '../services/notification.service';
|
||||||
import { SettingsService } from '../services/settings.service';
|
import { SettingsService } from '../services/settings.service';
|
||||||
import { ICustomizationSettings } from '../interfaces/ISettings';
|
import { ICustomizationSettings } from '../interfaces/ISettings';
|
||||||
|
import { IResetPasswordToken } from '../interfaces/IUser';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './tokenresetpassword.component.html',
|
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,
|
constructor(private identityService: IdentityService, private router: Router, private route: ActivatedRoute, private notify: NotificationService,
|
||||||
private fb: FormBuilder, private settingsService: SettingsService) {
|
private fb: FormBuilder, private settingsService: SettingsService) {
|
||||||
|
|
||||||
this.route.params
|
this.route.queryParams
|
||||||
.subscribe(params => {
|
.subscribe((params:Params) => {
|
||||||
|
debugger;
|
||||||
this.form = this.fb.group({
|
this.form = this.fb.group({
|
||||||
email: ["", [Validators.required]],
|
email: ["", [Validators.required]],
|
||||||
password: ["", [Validators.required]],
|
password: ["", [Validators.required]],
|
||||||
|
@ -31,7 +33,7 @@ export class TokenResetPasswordComponent implements OnInit {
|
||||||
customizationSettings: ICustomizationSettings;
|
customizationSettings: ICustomizationSettings;
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit() : void {
|
||||||
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
|
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");
|
this.notify.error("Validation", "Email address is required");
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var token = form.value as IResetPasswordToken;
|
||||||
this.identityService.resetPassword(form.value).subscribe(x => {
|
this.identityService.resetPassword(token).subscribe(x => {
|
||||||
if (x.successful) {
|
if (x.successful) {
|
||||||
this.notify.success("Success", `Your Password has been reset`)
|
this.notify.success("Success", `Your Password has been reset`)
|
||||||
this.router.navigate(['login']);
|
this.router.navigate(['login']);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
@ -434,20 +435,23 @@ namespace Ombi.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have the user
|
// 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
|
// We now need to email the user with this token
|
||||||
var emailSettings = await EmailSettings.GetSettingsAsync();
|
var emailSettings = await EmailSettings.GetSettingsAsync();
|
||||||
var customizationSettings = await CustomizationSettings.GetSettingsAsync();
|
var customizationSettings = await CustomizationSettings.GetSettingsAsync();
|
||||||
var appName = (string.IsNullOrEmpty(customizationSettings.ApplicationName)
|
var appName = (string.IsNullOrEmpty(customizationSettings.ApplicationName)
|
||||||
? "Ombi"
|
? "Ombi"
|
||||||
: customizationSettings.ApplicationName);
|
: customizationSettings.ApplicationName);
|
||||||
|
|
||||||
|
|
||||||
|
var url =
|
||||||
|
$"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}";
|
||||||
await EmailProvider.Send(new NotificationMessage
|
await EmailProvider.Send(new NotificationMessage
|
||||||
{
|
{
|
||||||
To = user.Email,
|
To = user.Email,
|
||||||
Subject = $"{appName} Password Reset",
|
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/>" +
|
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);
|
}, emailSettings);
|
||||||
|
|
||||||
return defaultMessage;
|
return defaultMessage;
|
||||||
|
@ -461,7 +465,7 @@ namespace Ombi.Controllers
|
||||||
[HttpPost("resetpassword")]
|
[HttpPost("resetpassword")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ApiExplorerSettings(IgnoreApi = true)]
|
[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);
|
var user = await UserManager.FindByEmailAsync(token.Email);
|
||||||
|
|
||||||
|
@ -473,8 +477,9 @@ namespace Ombi.Controllers
|
||||||
Errors = new List<string> { "Please check you email." }
|
Errors = new List<string> { "Please check you email." }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
var validToken = WebUtility.UrlDecode(token.Token);
|
||||||
var tokenValid = await UserManager.ResetPasswordAsync(user, token.Token, token.Password);
|
validToken = validToken.Replace(" ", "+");
|
||||||
|
var tokenValid = await UserManager.ResetPasswordAsync(user, validToken, token.Password);
|
||||||
|
|
||||||
if (tokenValid.Succeeded)
|
if (tokenValid.Succeeded)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue