diff --git a/src/app/core/login/login-routing.module.ts b/src/app/core/login/login-routing.module.ts index 393e2f432..0263baf61 100644 --- a/src/app/core/login/login-routing.module.ts +++ b/src/app/core/login/login-routing.module.ts @@ -42,6 +42,11 @@ const routes: Routes = [ loadChildren: () => import('./pages/forgotten-password/forgotten-password.module') .then( m => m.CoreLoginForgottenPasswordPageModule), }, + { + path: 'changepassword', + loadChildren: () => import('./pages/change-password/change-password.module') + .then( m => m.CoreLoginChangePasswordPageModule), + }, ]; @NgModule({ diff --git a/src/app/core/login/pages/change-password/change-password.html b/src/app/core/login/pages/change-password/change-password.html new file mode 100644 index 000000000..f40dde4be --- /dev/null +++ b/src/app/core/login/pages/change-password/change-password.html @@ -0,0 +1,48 @@ + + + + + + + {{ 'core.login.changepassword' | translate }} + + + + + + + + + + + + + +

{{ 'core.login.forcepasswordchangenotice' | translate }}

+

{{ 'core.login.changepasswordinstructions' | translate }}

+
+
+ + {{ 'core.login.changepasswordbutton' | translate }} + +
+ + + +

{{ 'core.login.changepasswordreconnectinstructions' | translate }}

+
+
+ + {{ 'core.login.reconnect' | translate }} + +
+ + +

{{ 'core.login.changepasswordlogoutinstructions' | translate }}

+
+
+ + {{ logoutLabel | translate }} + +
+
diff --git a/src/app/core/login/pages/change-password/change-password.module.ts b/src/app/core/login/pages/change-password/change-password.module.ts new file mode 100644 index 000000000..f983cadd2 --- /dev/null +++ b/src/app/core/login/pages/change-password/change-password.module.ts @@ -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 {} diff --git a/src/app/core/login/pages/change-password/change-password.page.ts b/src/app/core/login/pages/change-password/change-password.page.ts new file mode 100644 index 000000000..b3ae64d02 --- /dev/null +++ b/src/app/core/login/pages/change-password/change-password.page.ts @@ -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; + } + +}