MOBILE-3565 login: Implement change password page

main
Dani Palou 2020-10-28 08:10:40 +01:00
parent 7e2436e7ca
commit 03f9723329
4 changed files with 174 additions and 0 deletions

View File

@ -42,6 +42,11 @@ const routes: Routes = [
loadChildren: () => import('./pages/forgotten-password/forgotten-password.module') loadChildren: () => import('./pages/forgotten-password/forgotten-password.module')
.then( m => m.CoreLoginForgottenPasswordPageModule), .then( m => m.CoreLoginForgottenPasswordPageModule),
}, },
{
path: 'changepassword',
loadChildren: () => import('./pages/change-password/change-password.module')
.then( m => m.CoreLoginChangePasswordPageModule),
},
]; ];
@NgModule({ @NgModule({

View File

@ -0,0 +1,48 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button [attr.aria-label]="'core.back' | translate"></ion-back-button>
</ion-buttons>
<ion-title>{{ 'core.login.changepassword' | translate }}</ion-title>
<ion-buttons slot="end">
<ion-button (click)="showHelp()" [attr.aria-label]="'core.help' | translate">
<ion-icon slot="icon-only" name="far-question-circle"></ion-icon>
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ng-container *ngIf="!changingPassword">
<ion-item class="ion-text-wrap" lines="none">
<ion-label>
<h2>{{ 'core.login.forcepasswordchangenotice' | translate }}</h2>
<p class="ion-padding-top">{{ 'core.login.changepasswordinstructions' | translate }}</p>
</ion-label>
</ion-item>
<ion-button class="ion-text-wrap ion-margin" expand="block" (click)="openChangePasswordPage()">
{{ 'core.login.changepasswordbutton' | translate }}
</ion-button>
</ng-container>
<ng-container *ngIf="changingPassword">
<ion-item class="ion-text-wrap" lines="none">
<ion-label>
<p>{{ 'core.login.changepasswordreconnectinstructions' | translate }}</p>
</ion-label>
</ion-item>
<ion-button class="ion-text-wrap ion-margin" expand="block" (click)="login()">
{{ 'core.login.reconnect' | translate }}
</ion-button>
</ng-container>
<ion-item class="ion-text-wrap" lines="none">
<ion-label>
<p>{{ 'core.login.changepasswordlogoutinstructions' | translate }}</p>
</ion-label>
</ion-item>
<ion-button class="ion-text-wrap ion-margin" expand="block" color="light" (click)="logout()">
{{ logoutLabel | translate }}
</ion-button>
</ion-list>
</ion-content>

View File

@ -0,0 +1,44 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CoreLoginChangePasswordPage } from './change-password.page';
const routes: Routes = [
{
path: '',
component: CoreLoginChangePasswordPage,
},
];
@NgModule({
imports: [
RouterModule.forChild(routes),
CommonModule,
IonicModule,
TranslateModule.forChild(),
CoreDirectivesModule,
],
declarations: [
CoreLoginChangePasswordPage,
],
exports: [RouterModule],
})
export class CoreLoginChangePasswordPageModule {}

View File

@ -0,0 +1,77 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreLoginHelper } from '@core/login/services/helper';
import { Translate } from '@singletons/core.singletons';
/**
* Page that shows instructions to change the password.
*/
@Component({
selector: 'page-core-login-change-password',
templateUrl: 'change-password.html',
})
export class CoreLoginChangePasswordPage {
changingPassword = false;
logoutLabel: string;
constructor() {
this.logoutLabel = CoreLoginHelper.instance.getLogoutLabel();
}
/**
* Show a help modal.
*/
showHelp(): void {
CoreDomUtils.instance.showAlert(
Translate.instance.instant('core.help'),
Translate.instance.instant('core.login.changepasswordhelp'),
);
}
/**
* Open the change password page in a browser.
*/
openChangePasswordPage(): void {
CoreLoginHelper.instance.openInAppForEdit(
CoreSites.instance.getCurrentSiteId(),
'/login/change_password.php',
undefined,
true,
);
this.changingPassword = true;
}
/**
* Login the user.
*/
login(): void {
CoreLoginHelper.instance.goToSiteInitialPage();
this.changingPassword = false;
}
/**
* Logout the user.
*/
logout(): void {
CoreSites.instance.logout();
this.changingPassword = false;
}
}