forgot password
This commit is contained in:
parent
2dc4e24674
commit
5e1a71546f
@ -1,7 +1,7 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from 'environments/environment';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { BehaviorSubject, Observable, of } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
@ -9,7 +9,14 @@ import { catchError } from 'rxjs/operators';
|
||||
})
|
||||
export class SessionService {
|
||||
private apiUrl = environment.apiEndpoint;
|
||||
constructor(private _http: HttpClient) { }
|
||||
private nameSource = new BehaviorSubject<string>('');
|
||||
name = this.nameSource.asObservable()
|
||||
|
||||
constructor(private _http: HttpClient) { }
|
||||
|
||||
getForgotDetails(params) {
|
||||
this.nameSource.next(params);
|
||||
}
|
||||
|
||||
getLoginToken(params): Observable<any> {
|
||||
console.log(params.email)
|
||||
@ -23,4 +30,10 @@ export class SessionService {
|
||||
// return this._http.post(this.apiUrl + 'login', {'email':params.email,'password':params.password})
|
||||
}
|
||||
|
||||
resetPasswordApi(forgotDetails,resetPassword): Observable<any> {
|
||||
console.log(forgotDetails,resetPassword)
|
||||
return this._http.post<any>(this.apiUrl + "reset-password/"+forgotDetails.email+'/'+forgotDetails.token,resetPassword)
|
||||
// return this._http.post(this.apiUrl + 'login', {'email':params.email,'password':params.password})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ export class ForgotPasswordComponent {
|
||||
this._ser.getForgotToken(forgotMail).subscribe(res => {
|
||||
console.log(res)
|
||||
this.forgotTokenEmail = res
|
||||
this._ser.getForgotDetails(this.forgotTokenEmail)
|
||||
this.router.navigate(['authentication/reset-password'])
|
||||
}, err => {
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ export class LoginComponent {
|
||||
}
|
||||
|
||||
openForgot() {
|
||||
this.router.navigate(['/forgot-password']);
|
||||
this.router.navigate(['authentication/forgot-password'])
|
||||
// this.router.navigate(['/home'])
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
import { SessionService } from 'app/session-services/session.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-reset-password',
|
||||
@ -9,10 +11,16 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
})
|
||||
export class ResetPasswordComponent implements OnInit {
|
||||
form: FormGroup;
|
||||
forgotApiDetails: string;
|
||||
|
||||
constructor() { }
|
||||
constructor(private router: Router,public _ser:SessionService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this._ser.name.subscribe(data=>{
|
||||
this.forgotApiDetails = data;
|
||||
console.log(this.forgotApiDetails)
|
||||
});
|
||||
|
||||
this.form = new FormGroup({
|
||||
password: new FormControl('',[Validators.required,Validators.maxLength(10)]),
|
||||
password2: new FormControl('',[Validators.required,Validators.maxLength(10)]),
|
||||
@ -24,14 +32,17 @@ export class ResetPasswordComponent implements OnInit {
|
||||
|
||||
submit(){
|
||||
console.log(this.form.value)
|
||||
return;
|
||||
// this._ser.getForgotToken(forgotMail).subscribe(res => {
|
||||
// console.log(res)
|
||||
// this.forgotTokenEmail = res
|
||||
// }, err => {
|
||||
this._ser.resetPasswordApi(this.forgotApiDetails,this.form.value).subscribe(res => {
|
||||
console.log(res)
|
||||
if(res.status == 200){
|
||||
this.router.navigate(['authentication/login'])
|
||||
}
|
||||
|
||||
// //alert(err.message);
|
||||
// })
|
||||
// this.forgotTokenEmail = res
|
||||
}, err => {
|
||||
|
||||
//alert(err.message);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user