forked from EVOgeek/Vmeda.Online
		
	MOBILE-2941 login: Display forgot password button in reconnect
This commit is contained in:
		
							parent
							
								
									6557793227
								
							
						
					
					
						commit
						d44100f757
					
				| @ -19,7 +19,6 @@ import { CoreAppProvider } from '@providers/app'; | ||||
| import { CoreEventsProvider } from '@providers/events'; | ||||
| import { CoreSitesProvider } from '@providers/sites'; | ||||
| import { CoreDomUtilsProvider } from '@providers/utils/dom'; | ||||
| import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||
| import { CoreLoginHelperProvider } from '../../providers/helper'; | ||||
| import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||||
| import { CoreConfigConstants } from '../../../../configconstants'; | ||||
| @ -53,7 +52,7 @@ export class CoreLoginCredentialsPage { | ||||
| 
 | ||||
|     constructor(private navCtrl: NavController, navParams: NavParams, fb: FormBuilder, private appProvider: CoreAppProvider, | ||||
|             private sitesProvider: CoreSitesProvider, private loginHelper: CoreLoginHelperProvider, | ||||
|             private domUtils: CoreDomUtilsProvider, private translate: TranslateService, private utils: CoreUtilsProvider, | ||||
|             private domUtils: CoreDomUtilsProvider, private translate: TranslateService, | ||||
|             private eventsProvider: CoreEventsProvider) { | ||||
| 
 | ||||
|         this.siteUrl = navParams.get('siteUrl'); | ||||
| @ -230,26 +229,7 @@ export class CoreLoginCredentialsPage { | ||||
|      * Forgotten password button clicked. | ||||
|      */ | ||||
|     forgottenPassword(): void { | ||||
|         if (this.siteConfig && this.siteConfig.forgottenpasswordurl) { | ||||
|             // URL set, open it.
 | ||||
|             this.utils.openInApp(this.siteConfig.forgottenpasswordurl); | ||||
| 
 | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         // Check if password reset can be done through the app.
 | ||||
|         const modal = this.domUtils.showModalLoading(); | ||||
|         this.loginHelper.canRequestPasswordReset(this.siteUrl).then((canReset) => { | ||||
|             if (canReset) { | ||||
|                 this.navCtrl.push('CoreLoginForgottenPasswordPage', { | ||||
|                     siteUrl: this.siteUrl, username: this.credForm.value.username | ||||
|                 }); | ||||
|             } else { | ||||
|                 this.loginHelper.openForgottenPassword(this.siteUrl); | ||||
|             } | ||||
|         }).finally(() => { | ||||
|             modal.dismiss(); | ||||
|         }); | ||||
|         this.loginHelper.forgottenPasswordClicked(this.navCtrl, this.siteUrl, this.credForm.value.username, this.siteConfig); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -49,6 +49,11 @@ | ||||
|             </form> | ||||
|         </ion-list> | ||||
| 
 | ||||
|         <!-- Forgotten password button. --> | ||||
|         <div padding-top> | ||||
|             <button ion-button block text-wrap color="light" (click)="forgottenPassword()">{{ 'core.login.forgotten' | translate }}</button> | ||||
|         </div> | ||||
| 
 | ||||
|         <!-- Identity providers. --> | ||||
|         <ion-list *ngIf="identityProviders && identityProviders.length" padding-top> | ||||
|             <ion-list-header text-wrap>{{ 'core.login.potentialidps' | translate }}</ion-list-header> | ||||
|  | ||||
| @ -161,6 +161,13 @@ export class CoreLoginReconnectPage { | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Forgotten password button clicked. | ||||
|      */ | ||||
|     forgottenPassword(): void { | ||||
|         this.loginHelper.forgottenPasswordClicked(this.navCtrl, this.siteUrl, this.credForm.value.username, this.siteConfig); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * An OAuth button was clicked. | ||||
|      * | ||||
|  | ||||
| @ -260,6 +260,38 @@ export class CoreLoginHelperProvider { | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Helper function to act when the forgotten password is clicked. | ||||
|      * | ||||
|      * @param {NavController} navCtrl NavController to use to navigate. | ||||
|      * @param {string} siteUrl Site URL. | ||||
|      * @param {string} username Username. | ||||
|      * @param {any} [siteConfig] Site config. | ||||
|      */ | ||||
|     forgottenPasswordClicked(navCtrl: NavController, siteUrl: string, username: string, siteConfig?: any): void { | ||||
|         if (siteConfig && siteConfig.forgottenpasswordurl) { | ||||
|             // URL set, open it.
 | ||||
|             this.utils.openInApp(siteConfig.forgottenpasswordurl); | ||||
| 
 | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         // Check if password reset can be done through the app.
 | ||||
|         const modal = this.domUtils.showModalLoading(); | ||||
| 
 | ||||
|         this.canRequestPasswordReset(siteUrl).then((canReset) => { | ||||
|             if (canReset) { | ||||
|                 navCtrl.push('CoreLoginForgottenPasswordPage', { | ||||
|                     siteUrl: siteUrl, username: username | ||||
|                 }); | ||||
|             } else { | ||||
|                 this.openForgottenPassword(siteUrl); | ||||
|             } | ||||
|         }).finally(() => { | ||||
|             modal.dismiss(); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Format profile fields, filtering the ones that shouldn't be shown on signup and classifying them in categories. | ||||
|      * | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user