Commit 07e4cef8 authored by Priyanka Vivekanand Upadhye's avatar Priyanka Vivekanand Upadhye
Browse files

Merge branch '63-password-reset-api-integration' into 'master'

commit reset password changes

Closes #63

See merge request 92khra1mst/hft_awado_app!56
parents 9a7275fb fee6d9ec
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ResetPasswordPage } from './reset-password.page';
const routes: Routes = [
{
path: '',
component: ResetPasswordPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ResetPasswordPageRoutingModule {}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { ResetPasswordPageRoutingModule } from './reset-password-routing.module';
import { ResetPasswordPage } from './reset-password.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
ResetPasswordPageRoutingModule
],
declarations: [ResetPasswordPage]
})
export class ResetPasswordPageModule {}
<ion-header>
<ion-toolbar>
<ion-title>Reset Password</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-grid>
<ion-row justify-content-center>
<ion-col align-self-center size-md="6" size-lg="5" size-xs="12">
<div padding>
<img src="../../../assets/images/bike2gologo.png">
</div>
<div class="ion-text">
<h3>Reset Password</h3>
</div>
<ion-item ><ion-input type="text" [value]="username" disabled="true"></ion-input></ion-item>
<ion-item ><ion-input type="password" [(ngModel)]="oldPassword" placeholder="Old Password"></ion-input></ion-item>
<ion-item ><ion-input type="password" [(ngModel)]="newPassword" placeholder="New Password"></ion-input></ion-item>
<ion-item ><ion-input type="password" [(ngModel)]="confirmPassword" placeholder="Confirm Password"></ion-input></ion-item>
<div padding>
<ion-button size="large" expand="block" (click)="resetPassword()">Reset Password</ion-button>
</div>
<div padding>
<ion-button size="large" expand="block" (click)="login()">Login</ion-button>
</div>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ResetPasswordPage } from './reset-password.page';
describe('ResetPasswordPage', () => {
let component: ResetPasswordPage;
let fixture: ComponentFixture<ResetPasswordPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ResetPasswordPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(ResetPasswordPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Storage } from '@ionic/storage';
import { ToastService } from '../../services/toast.service';
import { UserService } from '../../services/user.service';
import { RestService } from '../../rest.service';
@Component({
selector: 'app-reset-password',
templateUrl: './reset-password.page.html',
styleUrls: ['./reset-password.page.scss'],
})
export class ResetPasswordPage implements OnInit {
oldPassword="";
newPassword="";
confirmPassword="";
username="";
ResetPasswordApi : Observable<any>;
constructor(private router: Router,
public httpClient: HttpClient,
private toastService: ToastService,
public restService: RestService,
private storage: Storage,
public userService: UserService) {
this.username = this.userService.getUsername();}
ngOnInit() {
}
login(){
this.router.navigateByUrl('/login');
}
resetPassword(){
if(this.confirmPassword!=this.newPassword)
this.toastService.showToast("Please Confirm Password Again");
else{
this.storage.get('token').then((token) => {
let url = 'http://193.196.52.237:8081/password-reset/'
const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
this.ResetPasswordApi = this.httpClient.post<any>(url, {"oldPassword":this.oldPassword,"newPassword": this.newPassword},{headers});
this.ResetPasswordApi.subscribe((resp) => {
console.log("PasswordChanged", resp);
this.toastService.showToast("Password Changed Sucessfully!Login Again");
this.router.navigateByUrl('/login');
}, (error) => {console.log(error)
//this.loadingService.hideLoader();
this.toastService.showToast("Please Try Again");
});
});
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment