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 message
Browse files Browse the repository at this point in the history
  • Loading branch information
Oswaldo Gallango committed Sep 27, 2016
1 parent 17483aa commit fcc81a4
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 21 deletions.
22 changes: 22 additions & 0 deletions src/api/util/httpRequestUtils.ts
@@ -0,0 +1,22 @@
/**
* Created by oswaldogallango on 9/27/16.
*/

export class HttpRequestUtils {

/**
* Get a map with the url querystring parameters
* @returns {Map<string, string>}
*/
getQueryParams(): Map<string, string> {
let split: string[] = window.location.search.substring(1).split('&');
let map: Map<string, string> = new Map();

split.forEach(param => {
let paramSplit: string[] = param.split('=');
map.set(paramSplit[0], paramSplit[1]);
});

return map;
}
}
19 changes: 4 additions & 15 deletions src/view/components/app.ts
Expand Up @@ -4,12 +4,13 @@ import {LoginPageComponent} from './common/login/login-page-component';
import {LoginService} from '../../api/services/login-service';
import {MainComponent} from './common/main-component/main-component';
import {Router} from '@ngrx/router';
import {HttpRequestUtils} from '../../api/util/httpRequestUtils';

@Component({
directives: [MainComponent, LoginPageComponent],
encapsulation: ViewEncapsulation.Emulated,
moduleId: __moduleName, // REQUIRED to use relative path in styleUrls
providers: [],
providers: [HttpRequestUtils],
selector: 'app',
styleUrls: ['app.css'],
templateUrl: ['app.html']
Expand All @@ -25,10 +26,10 @@ export class AppComponent {

// We are initializing dotcmsConfig in this component because it's the entry point and we need it
// ready for main-component, maybe we can do the request if the login it's success
constructor(private router: Router, private loginService: LoginService, dotcmsConfig: DotcmsConfig) {}
constructor(private router: Router, private loginService: LoginService, dotcmsConfig: DotcmsConfig, private httpRequestUtils: HttpRequestUtils) {}

ngOnInit(): void {
let queryParams: Map = this.getQueryParams();
let queryParams: Map = this.httpRequestUtils.getQueryParams();

if (<boolean> queryParams.get('resetPassword')) {
let token: string = queryParams.get('token');
Expand All @@ -49,16 +50,4 @@ export class AppComponent {
toggleMain(change: boolean): void {
this.login = change;
}

private getQueryParams(): Map<string, string> {
let split: string[] = window.location.search.substring(1).split('&');
let map: Map<string, string> = new Map();

split.forEach(param => {
let paramSplit: string[] = param.split('=');
map.set(paramSplit[0], paramSplit[1]);
});

return map;
}
}
Expand Up @@ -30,6 +30,7 @@ export class LoginComponent {

@Input() isLoginInProgress: boolean = false;
@Input() message: string = '';
@Input() passwordChanged: boolean = false;

@Output() recoverPassword = new EventEmitter<>();
@Output() login = new EventEmitter<LoginData>();
Expand Down Expand Up @@ -57,12 +58,12 @@ export class LoginComponent {
dotcmsBuildDateString: string = '';
mandatoryFieldError: string = '';
communityLicenseInfoMessage: string = '';

resetPasswordSuccess: 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'];
'angular.login.component.community.licence.message', 'reset-password-success'];

constructor(private loginService: LoginService, private ngZone: NgZone) {
this.language = '';
Expand Down Expand Up @@ -136,6 +137,7 @@ export class LoginComponent {
this.serverLabel = dataI18n.Server;
this.mandatoryFieldError = dataI18n['error.form.mandatory'];
this.communityLicenseInfoMessage = dataI18n['angular.login.component.community.licence.message'];
this.resetPasswordSuccess = dataI18n['reset-password-success'];


// Set dotCMS Info
Expand Down Expand Up @@ -163,6 +165,10 @@ export class LoginComponent {

this.language = currentLanguage.language + '_' + currentLanguage.country;
}

if (this.passwordChanged) {
this.message = this.resetPasswordSuccess;
}
}, (error) => {
console.log(error);
});
Expand Down
Expand Up @@ -2,13 +2,14 @@ import {Component,ViewEncapsulation} from '@angular/core';
import {LoginService} from '../../../../../api/services/login-service';
import {Router} from '@ngrx/router';
import {LoginComponent} from './login-component';
import {HttpRequestUtils} from '../../../../../api/util/httpRequestUtils';

@Component({
directives: [LoginComponent],
encapsulation: ViewEncapsulation.Emulated,
moduleId: __moduleName, // REQUIRED to use relative path in styleUrls
pipes: [],
providers: [],
providers: [HttpRequestUtils],
selector: 'dot-login-container',
styleUrls: [],
template: `
Expand All @@ -17,16 +18,21 @@ import {LoginComponent} from './login-component';
[isLoginInProgress] = "isLoginInProgress"
(login)="logInUser($event)"
(recoverPassword)="showForgotPassword()"
[passwordChanged]="passwordChanged"
>
</dot-login-component>
`,
})
export class LoginContainer{
private message:string;
private isLoginInProgress: boolean = false;
private passwordChanged: boolean = false;

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

constructor(private loginService: LoginService, private router: Router, private httprequestUtils: HttpRequestUtils) {
let queryParams: Map = this.httprequestUtils.getQueryParams();
if (<boolean> queryParams.get('changedPassword')) {
this.passwordChanged = queryParams.get('changedPassword');
}
}

logInUser(loginData:LoginData): void {
Expand Down Expand Up @@ -54,6 +60,7 @@ export class LoginContainer{
showForgotPassword(): void {
this.router.go('/public/forgotPassword');
}

}

export interface LoginData {
Expand Down
Expand Up @@ -60,7 +60,7 @@ export class ResetPasswordContainer {
}

private goToLogin(): void {
this.router.go('/public/login');
this.router.go('/public/login',{ 'changedPassword': true });
}

private cleanMessage(): void {
Expand Down

0 comments on commit fcc81a4

Please sign in to comment.