Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
dotCMS/core#9828 included sent email message
Browse files Browse the repository at this point in the history
  • Loading branch information
Oswaldo Gallango committed Sep 27, 2016
1 parent f6d5200 commit ab8232f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Expand Up @@ -22,27 +22,29 @@ import {ResponseView} from '../../../../../api/services/response-view';
})
export class ForgotPasswordContainer{

private message:string = '';
private message: string = '';
private email: string = '';

constructor( private loginService: LoginService, private router: Router) {

}

recoverPassword(forgotPasswordLogin:string): void {
this.message = '';
this.email = forgotPasswordLogin;

this.loginService.recoverPassword(forgotPasswordLogin).subscribe((resp:ResponseView) => {
this.goToLogin();
}, (resp:ResponseView) => {
if (!resp.existError("a-new-password-has-been-sent-to-x")){
if (!resp.existError('a-new-password-has-been-sent-to-x')){
this.message = resp.errorsMessages;
}else{
this.goToLogin();
}
});
}

goToLogin():void{
this.router.go('/public/login');
goToLogin(): void {
this.router.go('/public/login', { 'resetEmailSent': true, 'resetEmail': this.email});
}
}
Expand Up @@ -31,6 +31,8 @@ export class LoginComponent {
@Input() isLoginInProgress: boolean = false;
@Input() message: string = '';
@Input() passwordChanged: boolean = false;
@Input() resetEmailSent: boolean = false;
@Input() resetEmail: string = '';

@Output() recoverPassword = new EventEmitter<>();
@Output() login = new EventEmitter<LoginData>();
Expand Down Expand Up @@ -59,11 +61,14 @@ export class LoginComponent {
mandatoryFieldError: string = '';
communityLicenseInfoMessage: string = '';
resetPasswordSuccess: string = '';
resetEmailMessage: string ='';

isCommunityLicense: boolean = true;

private i18nMessages: Array<string> = [ 'Login', 'email-address', 'user-id', 'password', 'remember-me', 'sign-in',
'get-new-password', 'cancel', 'Server', 'error.form.mandatory',
'angular.login.component.community.licence.message', 'reset-password-success'];
'angular.login.component.community.licence.message', 'reset-password-success',
'a-new-password-has-been-sent-to-x'];

constructor(private loginService: LoginService, private ngZone: NgZone) {
this.language = '';
Expand Down Expand Up @@ -138,6 +143,7 @@ export class LoginComponent {
this.mandatoryFieldError = dataI18n['error.form.mandatory'];
this.communityLicenseInfoMessage = dataI18n['angular.login.component.community.licence.message'];
this.resetPasswordSuccess = dataI18n['reset-password-success'];
this.resetEmailMessage = dataI18n['a-new-password-has-been-sent-to-x'];


// Set dotCMS Info
Expand Down Expand Up @@ -169,6 +175,9 @@ export class LoginComponent {
if (this.passwordChanged) {
this.message = this.resetPasswordSuccess;
}
if (this.resetEmailSent) {
this.message = this.resetEmailMessage.replace('{0}', this.resetEmail);
}
}, (error) => {
console.log(error);
});
Expand Down
Expand Up @@ -19,6 +19,8 @@ import {HttpRequestUtils} from '../../../../../api/util/httpRequestUtils';
(login)="logInUser($event)"
(recoverPassword)="showForgotPassword()"
[passwordChanged]="passwordChanged"
[resetEmailSent]="resetEmailSent"
[resetEmail]="resetEmail"
>
</dot-login-component>
`,
Expand All @@ -27,12 +29,17 @@ export class LoginContainer{
private message:string;
private isLoginInProgress: boolean = false;
private passwordChanged: boolean = false;
private resetEmailSent: boolean = false;
private resetEmail: string = '';

constructor(private loginService: LoginService, private router: Router, private httprequestUtils: HttpRequestUtils) {
// TODO: change the httpRequestUtils.getQueryParams() with an NG2 method equivalent to QueryParams on NGRX.
let queryParams: Map = this.httprequestUtils.getQueryParams();
if (<boolean> queryParams.get('changedPassword')) {
this.passwordChanged = queryParams.get('changedPassword');
} else if (<boolean> queryParams.get('resetEmailSent')) {
this.resetEmailSent = queryParams.get('resetEmailSent');
this.resetEmail = decodeURIComponent(queryParams.get('resetEmail'));
}
}

Expand Down

0 comments on commit ab8232f

Please sign in to comment.