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