diff --git a/src/app/auth/reset-password/reset-password-routing.module.ts b/src/app/auth/reset-password/reset-password-routing.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..335ad7782c9d13b507b11957c05fd623f4763194 --- /dev/null +++ b/src/app/auth/reset-password/reset-password-routing.module.ts @@ -0,0 +1,17 @@ +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 {} diff --git a/src/app/auth/reset-password/reset-password.module.ts b/src/app/auth/reset-password/reset-password.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..30e0cd0b2c4ce8007ab7f512c40435be967ea959 --- /dev/null +++ b/src/app/auth/reset-password/reset-password.module.ts @@ -0,0 +1,20 @@ +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 {} diff --git a/src/app/auth/reset-password/reset-password.page.html b/src/app/auth/reset-password/reset-password.page.html new file mode 100644 index 0000000000000000000000000000000000000000..0a035ab58508624b3031d349e830a5295d9ab847 --- /dev/null +++ b/src/app/auth/reset-password/reset-password.page.html @@ -0,0 +1,42 @@ +<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 diff --git a/src/app/auth/reset-password/reset-password.page.scss b/src/app/auth/reset-password/reset-password.page.scss new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/app/auth/reset-password/reset-password.page.spec.ts b/src/app/auth/reset-password/reset-password.page.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..5628db6d2b7cef64da8482e0a8764ec079d1c638 --- /dev/null +++ b/src/app/auth/reset-password/reset-password.page.spec.ts @@ -0,0 +1,24 @@ +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(); + }); +}); diff --git a/src/app/auth/reset-password/reset-password.page.ts b/src/app/auth/reset-password/reset-password.page.ts new file mode 100644 index 0000000000000000000000000000000000000000..895132786724c8baf7985a81695afc9008c66180 --- /dev/null +++ b/src/app/auth/reset-password/reset-password.page.ts @@ -0,0 +1,56 @@ +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"); + }); + }); + } + } + +}